home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Digests / CSMP Digest / volume 3 / csmp-digest-v3-062 / doubleCR.1 < prev   
Encoding:
Text File  |  1995-12-31  |  118.2 KB  |  3,546 lines

  1. C.S.M.P. Digest             Tue, 04 Oct 94       Volume 3 : Issue 62
  2.  
  3. Today's Topics:
  4.  
  5.         (Q)Patched Traps and extention conflicts
  6.         HELP: How does one make a GWorld for printing?
  7.         How to call a C type code resource?
  8.         Is there a reasonable alternative to BalloonWriter?
  9.         Need help with MDEF UPP Question
  10.         OpenDoc Development Environments?
  11.         Q: Getting errors out of threads?
  12.         Shared Memory on Mac
  13.         Window Lists
  14.         preloaded CODE resources in fat binaries
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  19. (pottier@clipper.ens.fr).
  20.  
  21. The digest is a collection of article threads from the internet newsgroup
  22. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  23. regularly and want an archive of the discussions.  If you don't know what a
  24. newsgroup is, you probably don't have access to it.  Ask your systems
  25. administrator(s) for details.  If you don't have access to news, you may
  26. still be able to post messages to the group by using a mail server like
  27. anon.penet.fi (mail help@anon.penet.fi for more information).
  28.  
  29. Each issue of the digest contains one or more sets of articles (called
  30. threads), with each set corresponding to a 'discussion' of a particular
  31. subject.  The articles are not edited; all articles included in this digest
  32. are in their original posted form (as received by our news server at
  33. nef.ens.fr).  Article threads are not added to the digest until the last
  34. article added to the thread is at least two weeks old (this is to ensure that
  35. the thread is dead before adding it to the digest).  Article threads that
  36. consist of only one message are generally not included in the digest.
  37.  
  38. The digest is officially distributed by two means, by email and ftp.
  39.  
  40. If you want to receive the digest by mail, send email to listserv@ens.fr
  41. with no subject and one of the following commands as body:
  42.     help                        Sends you a summary of commands
  43.     subscribe csmp-digest Your Name    Adds you to the mailing list
  44.     signoff csmp-digest            Removes you from the list
  45. Once you have subscribed, you will automatically receive each new
  46. issue as it is created.
  47.  
  48. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  49. Questions related to the ftp site should be directed to
  50. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  51. digest are available there.
  52.  
  53. Also, the digests are available to WAIS users.  To search back issues
  54. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  55. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  56.  
  57.  
  58. -------------------------------------------------------
  59.  
  60. >From especkma@halcyon.com (Erik A. Speckman)
  61. Subject: (Q)Patched Traps and extention conflicts
  62. Date: Mon, 19 Sep 1994 14:49:05 -0700
  63. Organization: The Future Fair
  64.  
  65. I am trying to track down the causes of some instabillities in my System
  66. configuration and I would appreciate having a few questions answered.
  67.  
  68. I have used Andrew Welch's Init Tracker to give me a report of what
  69. extensions patch what traps at startup.  I have noticed that a few traps
  70. are patched by multiple extentions.
  71.  
  72. All of the extensions seem to do what they are supposed to so I was
  73. wondering how it works that multiple extentions can patch the same trap? 
  74. Do they each tag some more code like a subroutine call on to the end of the
  75. trap when they each load?
  76.  
  77. The multi-patched trap that catches my attention is: 
  78.  
  79. _Get1IxResource
  80.  
  81. because it is patched by MacTCP DNR, among others and I have been having
  82. problems which end up effecting DNR after the system has been up a while.
  83.  
  84. Thanks.
  85.  
  86. Erik
  87.  
  88.  
  89.  
  90.  
  91.  
  92. ______________________________________________________________________
  93. Erik A. Speckman       Seattle, Washington      Good Brain Doesn't Suck
  94. especkma@reed.edu                                  especkma@halcyon.com
  95.  
  96. +++++++++++++++++++++++++++
  97.  
  98. >From Tony Andreoli <andreoli@owens.ridgecrest.ca.us>
  99. Date: Tue, 20 Sep 1994 01:32:36 GMT
  100. Organization: RidgeNet - SLIP/PPP Internet, Ridgecrest, CA. (619) 371-3501
  101.  
  102. In article <9668AAA35561.106B96@blv-pm1-ip14.halcyon.com> Erik A.
  103. Speckman, especkma@halcyon.com writes:
  104. >All of the extensions seem to do what they are supposed to so I was
  105. >wondering how it works that multiple extentions can patch the same trap? 
  106. >Do they each tag some more code like a subroutine call on to the end of
  107. the
  108. >trap when they each load?
  109.  
  110. My understanding of patch trapping is this:
  111.  
  112. The first thing you do when patching a trap, is go to the trap dispatch
  113. table, and get the address for the code associated with the trap, and
  114. store this value, so you're patch can call it when it's done.  The last
  115. thing you do is set the address of your trap in the address table as the
  116. current address for the related trap.
  117.  
  118. Thus, if extension "A" patches a trap, then extension "B" attempts to
  119. patch the same trap, the execution order will be B -> A -> original trap,
  120. providing of course, that each patch calls the previously set trap
  121. (obtained when the trap was loaded).
  122.  
  123. Hope this makes some sense.
  124.  
  125. Tony Andreoli
  126.  
  127. ---------------------------
  128.  
  129. >From jscho@uclink.berkeley.edu (John S. Cho)
  130. Subject: HELP: How does one make a GWorld for printing?
  131. Date: Tue, 20 Sep 1994 16:43:35 -0800
  132. Organization: University of California, Berkeley
  133.  
  134. How does one change the resolution (from 72dpi to 300dpi or more) on a
  135. GWorld or offscreen bitmap? I need to store drawings into a GWorld to
  136. later be outputed to a printer. The problem I'm having right now is that
  137. all text I draw is being outputed by the printer at 72dpi which makes a
  138. lot of sense since the version saved in the GWorld is also at 72dpi. Is
  139. there a way to keep the resolution and use CopyBits to transfer the
  140. drawing from the GWorld to the printer?
  141.  
  142. Johnny
  143.          ._/ John Seungwon Cho (Koden)       ( "If not today nor yet tomorrow,
  144.         ._/ koden@well.com                    `.   then some other day."
  145.  ._/   ._/ jscho@{uclink,soda,ocf}.berkeley.edu )
  146. ._/._/._/ University of California, Berkeley  .'              - Dream Theater
  147.  
  148. +++++++++++++++++++++++++++
  149.  
  150. >From gurgle@dnai.com (Pete Gontier)
  151. Date: Tue, 20 Sep 1994 17:13:19 -0800
  152. Organization: Integer Poet Software
  153.  
  154. In article <jscho-2009941643350001@de32.reshall.berkeley.edu>,
  155. jscho@uclink.berkeley.edu wrote:
  156.  
  157. > How does one change the resolution (from 72dpi to 300dpi or more) on a
  158. > GWorld or offscreen bitmap? I need to store drawings into a GWorld to
  159. > later be outputed to a printer. The problem I'm having right now is that
  160. > all text I draw is being outputed by the printer at 72dpi which makes a
  161. > lot of sense since the version saved in the GWorld is also at 72dpi. Is
  162. > there a way to keep the resolution and use CopyBits to transfer the
  163. > drawing from the GWorld to the printer?
  164.  
  165. First I feel like I ought to point out that text is handled quite nicely
  166. by most printer drivers such that you don't have to worry about resolution
  167. if you draw the text directly into a printing GrafPort. (The printers that
  168. don't handle text this way are the ones that are no longer on the market
  169. and the ones that don't print any higher than 72 DPI in the first place.
  170. :-) If you don't need high resolution for the rest of your output, allow
  171. me to suggest you defer the text drawing until you are actually printing.
  172. If this can't work for you, read on.
  173.  
  174. Off-screen pixel maps don't really have DPI; they just have dimensions in
  175. terms of pixels. Theoretically, a pixel could be four feet or a single
  176. micron across. However, when you print, a pixel does have dimensions;
  177. namely 72 DPI, as you have discovered. (Monitors are *supposed to be* 72
  178. DPI, but many are not. Also, printers have varying DPI, but for historical
  179. reasons printer drivers almost universally report that they are 72 DPI
  180. unless you go out of your way to obtain the true numbers.) Good news: you
  181. can change the DPI recognized by the driver.
  182.  
  183. Off the top of my head, what you probably want to do is:
  184.  
  185.     a) Figure out the resolution of the current printer with PrGeneral.
  186.     b) Create a pixel map according to the dimensions of the page and
  187.        the resolution of the printer. It's going to be big. :-)
  188.     c) Make sure you set the resolution of the driver when printing.
  189.     b) CopyBits the pixel map into the printing GrafPort. You will probably
  190.        specify a destination rectangle which appears to scale your output,
  191.        but I suspect the printer driver QD bottleneck will know that you've
  192.        tweaked the resolution and do the right thing.
  193.  
  194. In order to make the memory consumption reasonable, you may have to
  195. process the pixel map in bands instead of an entire page at a time.
  196.  
  197. Anyway, I could be wrong about the details of this, but the documentation
  198. for PrGeneral will probably be much more illuminating.
  199.  
  200. -- 
  201.  
  202.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  203.  
  204.  "I saw John Norstad with Elvis! And they were varnishing waffles!"
  205.       -- Peter Cohen <flargh@tiac.net>
  206.  
  207. ---------------------------
  208.  
  209. >From ferrari@netaxs.com (Darrell Turner)
  210. Subject: How to call a C type code resource?
  211. Date: Thu, 15 Sep 1994 15:02:39 -0500
  212. Organization: Haha, None here
  213.  
  214. Hi, I'm trying to re-write the DNR.c for Pascal.  As far as I can tell, the
  215. dnrp code resource uses a C type calling convention (register based), so I
  216. must pop my stuff off the stack, and put it into the registers.  I've done
  217. a little of the inline assembly, but I don't know how to put the second to
  218. last paramter in d0( or whatever register C expects the first param to be
  219. in).
  220.  
  221.  function OpenResolverProc (num: longint; fileName: string; dnr: ProcPtr):
  222. OSErr;
  223.  inline
  224.   $205f, $4e90, $3E80; 
  225.  
  226. {$205f   move.l (a7)+,a0        ;dnr: ProcPtr}
  227. {$4e90   jsrs}
  228. {$3e80   puts result in}
  229.  
  230. Thanks for any help you can be!
  231.  
  232. +++++++++++++++++++++++++++
  233.  
  234. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  235. Date: Fri, 16 Sep 1994 11:04:29 +0800
  236. Organization: Department of Computer Science, The University of Western Australia
  237.  
  238. In article <ferrari-150994150240@slip-55.netaxs.com>, ferrari@netaxs.com
  239. (Darrell Turner) wrote:
  240.  
  241. >Hi, I'm trying to re-write the DNR.c for Pascal.
  242.  
  243. Four solutions to your problem...
  244.  
  245. #1 Use C glue.
  246. #2 Use assembly glue.
  247. #3 Do some horrible kludge using inlines (put the parameters in backwards
  248.    and then use the in-line to clean up the stack)
  249. #4 FTP Peter Lewis' sample code and figure out how he did it.
  250.      ftp://redback.cs.uwa.edu.au//Others/PeterLewis/
  251.  
  252. Personally, I would start at the end of this list and work backwards.
  253.  
  254. Share and Enjoy.
  255. -- 
  256. Quinn "The Eskimo!"        "Scout in a can. Simple, cheap, easy
  257.                             to use and it's expendable!"
  258.  
  259. +++++++++++++++++++++++++++
  260.  
  261. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  262. Date: 16 Sep 94 16:52:02 +1200
  263. Organization: University of Waikato, Hamilton, New Zealand
  264.  
  265. In article <ferrari-150994150240@slip-55.netaxs.com>, ferrari@netaxs.com (Darrell Turner) writes:
  266.  
  267. > Hi, I'm trying to re-write the DNR.c for Pascal.  As far as I can tell, the
  268. > dnrp code resource uses a C type calling convention (register based), so I
  269. > must pop my stuff off the stack, and put it into the registers.  I've done
  270. > a little of the inline assembly, but I don't know how to put the second to
  271. > last paramter in d0( or whatever register C expects the first param to be
  272. > in).
  273. >
  274. >  function OpenResolverProc (num: longint; fileName: string; dnr: ProcPtr):
  275. > OSErr;
  276. >  inline
  277. >   $205f, $4e90, $3E80;
  278. >
  279. > {$205f   move.l (a7)+,a0        ;dnr: ProcPtr}
  280. > {$4e90   jsrs}
  281. > {$3e80   puts result in}
  282.  
  283. The C convention is still stack-based for arguments, not register-based.
  284. The difference from Pascal is that arguments are stacked from right to
  285. left, not left to right, and everything is extended to 32 bits if it's
  286. smaller. Also the caller pops the arguments off the stack, not the callee.
  287. And finally, a result not exceeding 32 bits is returned in D0.
  288.  
  289. Put this all together, and the glue you seek for the above routine (nicely
  290. formatted the way I like it) is
  291.  
  292.     Function OpenResolver
  293.       (
  294.     FileName : String; {?}
  295.     dnr : ProcPtr
  296.       ) : OSErr;
  297.  
  298.     Inline
  299.         $205F,            { move.l (sp)+, a0 }
  300.         $2F3C, $0000, $0001,    { move.l #OPENRESOLVER, -(sp) }
  301.         $4E90,            { jsr (a0) }
  302.         $508F,            { addq.l #8, sp } { pop args }
  303.         $3E80;            { move.w d0, (sp) } { return result }
  304.  
  305. By the way, I'm not sure about the type of the FileName argument: since this
  306. is C code, it probably expects a string with a terminating null, and no
  307. length byte on the front.
  308.  
  309. Hope this helps.
  310.  
  311. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  312. Info & Tech Services Division              fax: +64-7-838-4066
  313. University of Waikato            electric mail: ldo@waikato.ac.nz
  314. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  315.  
  316. +++++++++++++++++++++++++++
  317.  
  318. >From calbear@crl.com (Howard H. Fukuda)
  319. Date: 16 Sep 1994 03:01:34 -0700
  320. Organization: CRL Dialup Internet Access    (415) 705-6060  [login: guest]
  321.  
  322. Darrell Turner (ferrari@netaxs.com) wrote:
  323. > Hi, I'm trying to re-write the DNR.c for Pascal.  As far as I can tell, the
  324. > dnrp code resource uses a C type calling convention (register based), so I
  325. > must pop my stuff off the stack, and put it into the registers.  I've done
  326. > a little of the inline assembly, but I don't know how to put the second to
  327. > last paramter in d0( or whatever register C expects the first param to be
  328. > in).
  329. >
  330. >  function OpenResolverProc (num: longint; fileName: string; dnr: ProcPtr):
  331. > OSErr;
  332. >  inline
  333. >   $205f, $4e90, $3E80; 
  334.  
  335. > {$205f   move.l (a7)+,a0        ;dnr: ProcPtr}
  336. > {$4e90   jsrs}
  337. > {$3e80   puts result in}
  338.  
  339. Well, I'm not familiar with DNR.c, but in general C compilers for the 
  340. Macintosh do not put parameters in registers, although D0 is used for the 
  341. return values. Mac C compilers usually push parameters onto the stack 
  342. from right to left. So assuming DNR.C is:
  343.  
  344. short DNR (long num, char *fileName);
  345.  
  346. you can call it with the following assembly language code (MPW Assembler 
  347. source)::
  348.  
  349. CallSomeCode        FUNC                EXPORT
  350. StackFrame          RECORD              {A6Link},DECR
  351. result              DS.W                1
  352. ParamBegin          EQU                 *
  353. num                 DS.L                1
  354. fileName            DS.L                1
  355. dnr                 DS.L                1
  356. ParamSize           EQU                 ParamBegin-*
  357. RetAddr             DS.L                1
  358. A6Link              DS.L                1
  359. LocalSize           EQU                 *
  360.                     ENDR
  361.                     WITH                StackFrame
  362.                     LINK                A6,#LocalSize
  363.                     MOVE.L              fileName(A6),-(SP)
  364.                     MOVE.L              num(A6),-(SP)
  365.                     MOVEA.L             dnr(A6),A0
  366.                     JSR                 (A0)
  367.                     UNLK                A6
  368.                     MOVEA.L             (SP)+,A0
  369.                     LEA                 ParamSize(SP),SP
  370.                     JMP                 (A0)
  371.                     ENDF
  372.  
  373. Which assembles down to:
  374.  
  375. 00000000: 4E56 0000          LINK       A6,#$0000
  376. 00000004: 2F2E 000C          MOVE.L     $000C(A6),-(A7)
  377. 00000008: 2F2E 0010          MOVE.L     $0010(A6),-(A7)
  378. 0000000C: 206E 0008          MOVEA.L    $0008(A6),A0
  379. 00000010: 4E90               JSR        (A0)
  380. 00000012: 4E5E               UNLK       A6
  381. 00000014: 205F               MOVEA.L    (A7)+,A0
  382. 00000016: 4FEF 000C          LEA        $000C(A7),A7
  383. 0000001A: 4ED0               JMP        (A0)
  384.  
  385. If DNR.c is really putting parameters in registers, then just put them in 
  386. the right registers instead of the stack.
  387.  
  388. Howard
  389.  
  390. -- 
  391. - -----------------------------------------------------------------------------
  392. Howard H. Fukuda                                                calbear@crl.com
  393. Macintosh Software Engineer                                         "Go Bears!"
  394. ===============================================================================
  395.  
  396. +++++++++++++++++++++++++++
  397.  
  398. >From calbear@crl.com (Howard H. Fukuda)
  399. Date: 16 Sep 1994 03:31:41 -0700
  400. Organization: CRL Dialup Internet Access    (415) 705-6060  [login: guest]
  401.  
  402. Howard H. Fukuda (calbear@crl.com) wrote:
  403. > Which assembles down to:
  404. >
  405. > 00000000: 4E56 0000          LINK       A6,#$0000
  406. > 00000004: 2F2E 000C          MOVE.L     $000C(A6),-(A7)
  407. > 00000008: 2F2E 0010          MOVE.L     $0010(A6),-(A7)
  408. > 0000000C: 206E 0008          MOVEA.L    $0008(A6),A0
  409. > 00000010: 4E90               JSR        (A0)
  410. > 00000012: 4E5E               UNLK       A6
  411. > 00000014: 205F               MOVEA.L    (A7)+,A0
  412. > 00000016: 4FEF 000C          LEA        $000C(A7),A7
  413. > 0000001A: 4ED0               JMP        (A0)
  414.  
  415. Well, I goofed. I forgot to save the function result, so change:
  416.  
  417. 0000001A: 4ED0               JMP        (A0)
  418.  
  419. to:
  420.  
  421. 0000001A: 3E80               MOVE.W     D0,(A7)
  422. 0000001C: 4ED0               JMP        (A0)
  423.  
  424.  
  425. Howard
  426.  
  427. -- 
  428. - -----------------------------------------------------------------------------
  429. Howard H. Fukuda                                                calbear@crl.com
  430. Macintosh Software Engineer                                         "Go Bears!"
  431. ===============================================================================
  432.  
  433. +++++++++++++++++++++++++++
  434.  
  435. >From gurgle@dnai.com (Pete Gontier)
  436. Date: Fri, 16 Sep 1994 15:18:23 -0800
  437. Organization: Integer Poet Software
  438.  
  439. In article <quinn-1609941104290001@edu-dynamic7.educ.ecel.uwa.edu.au>,
  440. quinn@cs.uwa.edu.au (Quinn "The Eskimo!") wrote:
  441.  
  442. > #3 Do some horrible kludge using inlines (put the parameters in backwards
  443. >    and then use the in-line to clean up the stack)
  444.  
  445. As long as we're considering using something other than Peter Lewis' code,
  446. would it be so difficult to simply add 'pascal' keywords to "dnr.c" and
  447. write an interface file for Pascal? I suppose it would if you didn't have
  448. a C compiler. :-)
  449.  
  450. Anyway, my own suggestion for working with "dnr.c" is either use PL's
  451. stuff or modify the copy of "dnr.c" which comes with the NewsWatcher
  452. source. It evidently has siginificant fixes because, as its comments say,
  453. it was "crap". "I had to hack it to death to get it to work," writes
  454. Norstad. Given that NewsWatcher probably does about as many Mac-hosted DNS
  455. lookups as anything in the world except perhaps Eudora, I wouldn't be
  456. surprised if its "dnr.c" were more reliable.
  457.  
  458. -- 
  459.  
  460.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  461.  
  462.  "I saw John Norstad with Elvis! And they were varnishing waffles!"
  463.       -- Peter Cohen <flargh@tiac.net>
  464.  
  465. +++++++++++++++++++++++++++
  466.  
  467. >From gurgle@dnai.com (Pete Gontier)
  468. Date: Fri, 16 Sep 1994 10:42:28 -0800
  469. Organization: Integer Poet Software
  470.  
  471. In article <ferrari-150994150240@slip-55.netaxs.com>, ferrari@netaxs.com
  472. (Darrell Turner) wrote:
  473.  
  474. > Hi, I'm trying to re-write the DNR.c for Pascal.
  475.  
  476. If Peter Lewis hasn't already done this, I'm a monkey's uncle.
  477.  
  478. -- 
  479.  
  480.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  481.  
  482.  "I saw John Norstad with Elvis! And they were varnishing waffles!"
  483.       -- Peter Cohen <flargh@tiac.net>
  484.  
  485. +++++++++++++++++++++++++++
  486.  
  487. >From ferrari@netaxs.com (Darrell Turner)
  488. Date: Fri, 16 Sep 1994 23:14:48 -0500
  489. Organization: Haha, None here
  490.  
  491. In article <gurgle-1609941518230001@dynamic-216.dnai.com>, gurgle@dnai.com
  492. (Pete Gontier) wrote:
  493.  
  494. > In article <quinn-1609941104290001@edu-dynamic7.educ.ecel.uwa.edu.au>,
  495. > quinn@cs.uwa.edu.au (Quinn "The Eskimo!") wrote:
  496. > > #3 Do some horrible kludge using inlines (put the parameters in backwards
  497. > >    and then use the in-line to clean up the stack)
  498. > As long as we're considering using something other than Peter Lewis' code,
  499. > would it be so difficult to simply add 'pascal' keywords to "dnr.c" and
  500. > write an interface file for Pascal? I suppose it would if you didn't have
  501. > a C compiler. :-)
  502.  
  503. I have a C compiler, so it's worth a try, what I want to know is, can you
  504. compile a library in C that can be included in your project in Pascal?
  505.  
  506. > Anyway, my own suggestion for working with "dnr.c" is either use PL's
  507. > stuff or modify the copy of "dnr.c" which comes with the NewsWatcher
  508.  
  509. I did start from Newswatcher's dnr.c.  And BTW, I have seen PL's coode, and
  510. he did it via a library, and the code is UGGGGGGGGLY!, but I do appreciate
  511. the result of his programming eforts, I just can't stand to do my own
  512. programming with his libraries.  Magic numbers and everything, hehe... I
  513. want to release my efforts as an alternative to his libraries.
  514.  
  515. > source. It evidently has siginificant fixes because, as its comments say,
  516. > it was "crap". "I had to hack it to death to get it to work," writes
  517. > Norstad. Given that NewsWatcher probably does about as many Mac-hosted DNS
  518. > lookups as anything in the world except perhaps Eudora, I wouldn't be
  519. > surprised if its "dnr.c" were more reliable.
  520.  
  521. I have got OpenResolver, and Close Resolver to work, now i'm working on
  522. StrToAddr, and it's not going too well...
  523.  
  524. +++++++++++++++++++++++++++
  525.  
  526. >From gurgle@dnai.com (Pete Gontier)
  527. Date: Fri, 16 Sep 1994 21:59:33 -0800
  528. Organization: Integer Poet Software
  529.  
  530. In article <ferrari-160994231449@slip-55.netaxs.com>, ferrari@netaxs.com
  531. (Darrell Turner) wrote:
  532.  
  533. > > As long as we're considering using something other than Peter Lewis' code,
  534. > > would it be so difficult to simply add 'pascal' keywords to "dnr.c" and
  535. > > write an interface file for Pascal? I suppose it would if you didn't have
  536. > > a C compiler. :-)
  537. > I have a C compiler, so it's worth a try, what I want to know is, can you
  538. > compile a library in C that can be included in your project in Pascal?
  539.  
  540. Sure. Other way around, too. In MPW it's pretty clear how to do it because
  541. everything resolves to an object file. With the THINK compilers, I seem to
  542. remember you actually have to "Build Library" rather than expecting the
  543. compilers to load each other's project files. (You can use project files
  544. as libraries within THINK C and Symantec C++.) I've never done it with
  545. CodeWarrior, but I'd be surprised if it were not possible. There's also
  546. the possibility of mixing and matching. THINK Pascal and CodeWarrior C/C++
  547. read MPW objects, for example, and THINK C/Symantec C++ have a converter
  548. which allows you to use MPW objects.
  549.  
  550. -- 
  551.  
  552.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  553.  
  554.  "I saw John Norstad with Elvis! And they were varnishing waffles!"
  555.       -- Peter Cohen <flargh@tiac.net>
  556.  
  557. +++++++++++++++++++++++++++
  558.  
  559. >From ferrari@netaxs.com (Darrell Turner)
  560. Date: Sat, 17 Sep 1994 11:46:49 -0500
  561. Organization: Haha, None here
  562.  
  563. In article <gurgle-1609942159330001@dynamic-207.dnai.com>, gurgle@dnai.com
  564. (Pete Gontier) wrote:
  565.  
  566. > Sure. Other way around, too. In MPW it's pretty clear how to do it because
  567. > everything resolves to an object file. With the THINK compilers, I seem to
  568. > remember you actually have to "Build Library" rather than expecting the
  569. > compilers to load each other's project files. (You can use project files
  570. > as libraries within THINK C and Symantec C++.) I've never done it with
  571. > CodeWarrior, but I'd be surprised if it were not possible. There's also
  572. > the possibility of mixing and matching. THINK Pascal and CodeWarrior C/C++
  573. > read MPW objects, for example, and THINK C/Symantec C++ have a converter
  574. > which allows you to use MPW objects.
  575.  
  576. I compiled dnr.c into a library, and eventually got it to link with my
  577. project (no link errors).  But it seems to do exactly the same thing (bad
  578. crashes, jumping to wierd places and getting address errors).  I did make
  579. sure to convert the pascal strings to C strings, but it still doesnt
  580. work...
  581.  
  582. +++++++++++++++++++++++++++
  583.  
  584. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  585. Date: Sun, 18 Sep 1994 13:02:17 +0800
  586. Organization: NCRPDA, Curtin University
  587.  
  588. In article <ferrari-150994150240@slip-55.netaxs.com>, ferrari@netaxs.com
  589. (Darrell Turner) wrote:
  590.  
  591. >Hi, I'm trying to re-write the DNR.c for Pascal.  As far as I can tell, the
  592.  
  593. Well, that's an easy thing to fix:
  594.    Peter.
  595.  
  596. unit DNR;
  597.  
  598. interface
  599.  
  600.    uses
  601.       TCPTypes;
  602.  
  603.    type
  604.       ResultProcPtr = ProcPtr;
  605. { procedure ResultProc(hip:hostInfoPtr; userdata:ptr); }
  606.       ResultProc2Ptr = ProcPtr;
  607. { procedure ResultProc2(hmxip:HMXInfoPtr; userdata:ptr); }
  608.       EnumResultProcPtr = ProcPtr;
  609. { procedure EnumResultProc(cerp:cacheEntryRecordPtr; userdata:ptr); }
  610.  
  611.    function OpenResolver: OSErr;
  612.    procedure CloseResolver;
  613.    function StrToAddr (host: Str255; var rtnStruct: hostInfo; completion:
  614. ResultProcPtr; userdata: Ptr): OSErr;
  615.    procedure AddrToStr (addr: longInt; var s: str255);
  616.    function EnumCache (completion: EnumResultProcPtr; userdata: ptr): OSErr;
  617.    function AddrToName (addr: longInt; var hi: hostInfo; completion:
  618. ResultProcPtr; userdata: ptr): OSErr;
  619.    function HInfo (host: Str255; var hi: hmxInfoRec; completion:
  620. ResultProc2Ptr; userdata: ptr): OSErr;
  621.    function MXInfo (host: Str255; var mxi: hmxInfoRec; completion:
  622. ResultProc2Ptr; userdata: ptr): OSErr;
  623.  
  624. implementation
  625.  
  626.    uses
  627. {$IFC undefined THINK_Pascal}
  628.       Resources, Errors, Memory, 
  629. {$ENDC}
  630.       Folders;
  631.  
  632.    var
  633.       code: Handle;
  634.  
  635.    procedure GetSystemFolder (var vrn: integer; var dirID: longInt);
  636.    begin
  637.       if FindFolder(kOnSystemDisk, kSystemFolderType, false, vrn, dirID)
  638. <> noErr then begin
  639.          vrn := 0;
  640.          dirID := 0;
  641.       end;
  642.    end;
  643.  
  644.    procedure GetCPanelFolder (var vrn: integer; var dirID: longInt);
  645.    begin
  646.       if FindFolder(kOnSystemDisk, kControlPanelFolderType, false, vrn,
  647. dirID) <> noErr then begin
  648.          vrn := 0;
  649.          dirID := 0;
  650.       end;
  651.    end;
  652.  
  653. { SearchFolderForDNRP is called to search a folder for files that might }
  654. { contain the 'dnrp' resource }
  655.    function SearchFolderForDNRP (ftype, fcreator: OSType; vrn: integer;
  656. dirID: longInt): Handle;
  657.       var
  658.          pb: HParamBlockRec;
  659.          filename: Str63;
  660.          refnum: integer;
  661.          i: integer;
  662.          h: Handle;
  663.          err: OSErr;
  664.    begin
  665.       h := nil;
  666.       i := 1;
  667.       repeat
  668.          pb.ioNamePtr := @filename;
  669.          pb.ioVRefNum := vrn;
  670.          pb.ioDirID := dirID;
  671.          pb.ioFDirIndex := i;
  672.          i := i + 1;
  673.          err := PBHGetFInfoSync(@pb);
  674.          if err = noErr then begin
  675.             if (pb.ioFlFndrInfo.fdType = ftype) &
  676. (pb.ioFlFndrInfo.fdCreator = fcreator) then begin
  677.                SetResLoad(false);
  678.                refnum := HOpenResFile(vrn, dirID, filename, fsRdPerm);
  679.                SetResLoad(true);
  680.                if refnum <> -1 then begin
  681.                   h := Get1IndResource('dnrp', 1);
  682.                   if h <> nil then begin
  683.                      DetachResource(h);
  684.                   end;
  685.                   CloseResFile(refnum);
  686.                end;
  687.             end;
  688.          end;
  689.       until (err <> noErr) or (h <> nil);
  690.       SearchFolderForDNRP := h;
  691.    end;
  692.  
  693.    function SearchForDNRP: Handle;
  694.       var
  695.          h: Handle;
  696.          vrn: integer;
  697.          dirID: longInt;
  698.    begin
  699. { first search Control Panels for MacTCP 1.1 }
  700.       GetCPanelFolder(vrn, dirID);
  701.       h := SearchFolderForDNRP('cdev', 'ztcp', vrn, dirID);
  702.  
  703.       if h = nil then begin
  704. { next search System Folder for MacTCP 1.0.x }
  705.          GetSystemFolder(vrn, dirID);
  706.          h := SearchFolderForDNRP('cdev', 'mtcp', vrn, dirID);
  707.       end;
  708.  
  709.       if h = nil then begin
  710. { then search Control Panels for MacTCP 1.0.x }
  711.          GetCPanelFolder(vrn, dirID);
  712.          h := SearchFolderForDNRP('cdev', 'mtcp', vrn, dirID);
  713.       end;
  714.  
  715.       if h = nil then begin
  716. { finally, look in any open resource file }
  717.          h := Get1IndResource('dnrp', 1);
  718.          if h <> nil then begin
  719.             DetachResource(h);
  720.          end;
  721.       end;
  722.  
  723.       SearchForDNRP := h;
  724.    end;
  725.  
  726.    function CallOpenResolver (code: ptr): OSErr;
  727.    inline
  728.       $205F, $42A7, $4878, $0001, $4E90, $504F, $3E80;
  729.  
  730.    function OpenResolver: OSErr;
  731.       var
  732.          err: OSErr;
  733.    begin
  734.       code := SearchForDNRP;
  735.       if code = nil then begin
  736.          err := resNotFound;
  737.       end
  738.       else begin
  739.          HLock(code);
  740.          err := CallOpenResolver(code^);
  741.          if err <> noErr then begin
  742.             DisposeHandle(code);
  743.             code := nil;
  744.          end;
  745.       end;
  746.       OpenResolver := err;
  747.    end;
  748.  
  749.    procedure CallCloseResolver (code: ptr);
  750.    inline
  751.       $205F, $4878, $0002, $4E90, $584F;
  752.  
  753.    procedure CloseResolver;
  754.    begin
  755.       if code <> nil then begin
  756.          CallCloseResolver(code^);
  757.          DisposeHandle(code);
  758.       end;
  759.    end;
  760.  
  761.    procedure P2C (var name: string);
  762.       var
  763.          len: integer;
  764.    begin
  765.       len := length(name);
  766.       BlockMove(@name[1], @name, len);
  767.       name[len] := chr(0);
  768.    end;
  769.  
  770.    function CallStrToAddr (userdata: ptr; completion: ProcPtr; var
  771. rtnStruct: hostInfo; cname: ptr; code: ptr): OSErr;
  772.    inline
  773.       $205F, $4878, $0003, $4E90, $4FEF, $0014, $3E80;
  774.  
  775.    function StrToAddr (host: Str255; var rtnStruct: hostInfo; completion:
  776. ResultProcPtr; userdata: Ptr): OSErr;
  777.       var
  778.          err: OSErr;
  779.          len: integer;
  780.    begin
  781.       if code = nil then begin
  782.          err := notOpenErr;
  783.       end
  784.       else begin
  785.          P2C(host);
  786.          err := CallStrToAddr(userdata, completion, rtnStruct, @host, code^);
  787.       end;
  788.       StrToAddr := err;
  789.    end;
  790.  
  791.    procedure CallAddrToStr (cstr: ptr; addr: longInt; code: ptr);
  792.    inline
  793.       $205F, $4878, $0004, $4E90, $4FEF, $000C;
  794.  
  795.    procedure AddrToStr (addr: longInt; var s: str255);
  796.       var
  797.          len: integer;
  798.    begin
  799.       if code <> nil then begin
  800.          CallAddrToStr(@s, addr, code^);
  801.          len := 0;
  802.          while (s[len] <> chr(0)) & (len < 255) do begin
  803.             len := len + 1;
  804.          end;
  805.          BlockMove(@s, @s[1], len);
  806.          s[0] := chr(len);
  807.       end;
  808.    end;
  809.  
  810.    function CallEnumCache (userdata: ptr; completion: ProcPtr; code: ptr):
  811. OSErr;
  812.    inline
  813.       $205F, $4878, $0005, $4E90, $4FEF, $000C, $3E80;
  814.  
  815.    function EnumCache (completion: EnumResultProcPtr; userdata: ptr): OSErr;
  816.       var
  817.          err: OSErr;
  818.    begin
  819.       if code = nil then begin
  820.          err := notOpenErr;
  821.       end
  822.       else begin
  823.          err := CallEnumCache(userdata, completion, code^);
  824.       end;
  825.       EnumCache := err;
  826.    end;
  827.  
  828.    function CallAddrToName (userdata: ptr; completion: ProcPtr; var hi:
  829. hostInfo; addr: longInt; code: ptr): OSErr;
  830.    inline
  831.       $205F, $4878, $0006, $4E90, $4FEF, $0014, $3E80;
  832.  
  833.    function AddrToName (addr: longInt; var hi: hostInfo; completion:
  834. ResultProcPtr; userdata: ptr): OSErr;
  835.       var
  836.          err: OSErr;
  837.    begin
  838.       if code = nil then begin
  839.          err := notOpenErr;
  840.       end
  841.       else begin
  842.          err := CallAddrToName(userdata, completion, hi, addr, code^);
  843.       end;
  844.       AddrToName := err;
  845.    end;
  846.  
  847.    function CallHInfo (userdata: ptr; completion: ProcPtr; var hi:
  848. hmxInfoRec; name: ptr; code: ptr): OSErr;
  849.    inline
  850.       $205F, $4878, $0007, $4E90, $4FEF, $0014, $3E80;
  851.  
  852.    function HInfo (host: Str255; var hi: hmxInfoRec; completion:
  853. ResultProc2Ptr; userdata: ptr): OSErr;
  854.       var
  855.          err: OSErr;
  856.    begin
  857.       if code = nil then begin
  858.          err := notOpenErr;
  859.       end
  860.       else begin
  861.          P2C(host);
  862.          err := CallHInfo(userdata, completion, hi, @host, code^);
  863.       end;
  864.       HInfo := err;
  865.    end;
  866.  
  867.    function CallMXInfo (userdata: ptr; completion: ProcPtr; var hi:
  868. hmxInfoRec; name: ptr; code: ptr): OSErr;
  869.    inline
  870.       $205F, $4878, $0008, $4E90, $4FEF, $0014, $3E80;
  871.  
  872.    function MXInfo (host: Str255; var mxi: hmxInfoRec; completion:
  873. ResultProc2Ptr; userdata: ptr): OSErr;
  874.       var
  875.          err: OSErr;
  876.    begin
  877.       if code = nil then begin
  878.          err := notOpenErr;
  879.       end
  880.       else begin
  881.          P2C(host);
  882.          err := CallMXInfo(userdata, completion, mxi, @host, code^);
  883.       end;
  884.       MXInfo := err;
  885.    end;
  886.  
  887. end.
  888.  
  889. unit TCPTypes;
  890.  
  891. { TCPTypes © Peter Lewis, Oct 1991 }
  892. { This source is Freeware }
  893.  
  894. interface
  895.  
  896. {$IFC undefined THINK_Pascal}
  897.    uses
  898.       Types, OSUtils;
  899. {$ENDC}
  900.  
  901. { MacTCP return Codes in the range -23000 through -23049 }
  902.    const
  903.       inProgress = 1;                     { I/O in progress }
  904.  
  905.       ipBadLapErr = -23000;               { bad network configuration }
  906.       ipBadCnfgErr = -23001;           { bad IP configuration error }
  907.       ipNoCnfgErr = -23002;               { missing IP or LAP
  908. configuration error }
  909.       ipLoadErr = -23003;              { error in MacTCP load }
  910.       ipBadAddrErr = -23004;              { error in getting address }
  911.       connectionClosingErr = -23005;         { connection is closing }
  912.       invalidLengthErr = -23006;
  913.       connectionExistsErr = -23007;       { request conflicts with
  914. existing connection }
  915.       connectionDoesntExistErr = -23008;     { connection does not exist }
  916.       insufficientResourcesErr = -23009;     { insufficient resources to
  917. perform request }
  918.       invalidStreamPtrErr = -23010;
  919.       streamAlreadyOpenErr = -23011;
  920.       connectionTerminatedErr = -23012;
  921.       invalidBufPtrErr = -23013;
  922.       invalidRDSErr = -23014;
  923.       invalidWDSErr = -23014;
  924.       openFailedErr = -23015;
  925.       commandTimeoutErr = -23016;
  926.       duplicateSocketErr = -23017;
  927.  
  928. { Error codes from internal IP functions }
  929.       ipDontFragErr = -23032;          { Packet too large to send w/o
  930. fragmenting }
  931.       ipDestDeadErr = -23033;          { destination not responding }
  932.       icmpEchoTimeoutErr = -23035;     { ICMP echo timed-out }
  933.       ipNoFragMemErr = -23036;         { no memory to send fragmented pkt }
  934.       ipRouteErr = -23037;             { can't route packet off-net }
  935.  
  936.       nameSyntaxErr = -23041;
  937.       cacheFaultErr = -23042;
  938.       noResultProcErr = -23043;
  939.       noNameServerErr = -23044;
  940.       authNameErrErr = -23045;
  941.       noAnsErr = -23046;
  942.       dnrErr = -23047;
  943.       outOfMemoryErr = -23048;
  944.  
  945. { connectionState }
  946.    const
  947.       CState_Closed = 0;
  948.       CState_Listening = 2;
  949.       CState_Opening1 = 4;
  950.       CState_Opening2 = 6;
  951.       CState_Established = 8;
  952.       CState_Closing1 = 10;
  953.       CState_Closing2 = 12;
  954.       CState_Closing3 = 16;
  955.       CState_Closing4 = 18;
  956.       CState_Closing5 = 20;
  957.       CState_PleaseClose = 14;
  958.  
  959.    type
  960.       AddrClasses = integer;
  961.    const
  962.       AC_A = 1;
  963.       AC_NS = 2;
  964.       AC_CNAME = 5;
  965.       AC_HINFO = 13;
  966.       AC_MX = 15;
  967.  
  968.    const
  969.       CTRUE = $FF;
  970.       CFALSE = $00;
  971.  
  972.    type
  973.       C_BOOLEAN = signedByte;
  974.       CSTRING = ptr;
  975.       CStr30 = packed array[0..29] of char;
  976.       CStr255 = packed array[0..255] of char;
  977.       ipAddr = longInt;
  978.       ipPort = integer;
  979.       StreamPtr = ptr;
  980.  
  981.    type
  982.       wdsType = record        { Write block for TCP driver. }
  983.             size: integer;          { Number of bytes. }
  984.             buffer: Ptr;            { Pointer to bytes. }
  985.             term: integer;          { Zero for end of blocks. }
  986.          end;
  987.       wdsPtr = ^wdsType;
  988.       wdsEntry = record
  989.             size: integer;          { Number of bytes. }
  990.             buffer: Ptr;            { Pointer to bytes. }
  991.          end;
  992.  
  993.       hostInfo = record
  994.             rtnCode: longInt;
  995.             rtnHostName: str255;
  996.             addrs: array[1..4] of ipAddr;
  997.          end;
  998.       hostInfoPtr = ^hostInfo;
  999.  
  1000.    type
  1001.       HInfoRec = record
  1002.             cpuType: CStr30;
  1003.             osType: CStr30;
  1004.          end;
  1005.  
  1006.    type
  1007.       MXRec = record
  1008.             preference: integer; { unsigned! }
  1009.             exchange: CStr255;
  1010.          end;
  1011.  
  1012.    type
  1013.       hmxInfoRec = record
  1014.             rtcCode: integer;
  1015.             cname: CStr255;
  1016.             case integer of
  1017.                1: (
  1018.                      addr: array[1..4] of ipAddr;
  1019.                );
  1020.                2: (
  1021.                      hinfo: HInfoRec;
  1022.                );
  1023.                3: (
  1024.                      mx: MXRec;
  1025.                );
  1026.          end;
  1027.       hmxInfoRecPtr = ^hmxInfoRec;
  1028.  
  1029.    type
  1030.       cacheEntryRecord = record
  1031.             cname: CSTRING;
  1032.             typ: integer;
  1033.             class: integer;
  1034.             ttl: longInt;
  1035.             case integer of
  1036.                1: (
  1037.                      name: CSTRING;
  1038.                );
  1039.                2: (
  1040.                      addr: ipAddr;
  1041.                );
  1042.          end;
  1043.       cacheEntryRecordPtr = ^cacheEntryRecord;
  1044.  
  1045.    const { csCodes for the TCP driver: }
  1046.       TCPcsGetMyIP = 15;
  1047.       TCPcsEchoICMP = 17;
  1048.       TCPcsLAPStats = 19;
  1049.       TCPcsCreate = 30;
  1050.       TCPcsPassiveOpen = 31;
  1051.       TCPcsActiveOpen = 32;
  1052. {    TCPcsActOpenWithData = 33;}
  1053.       TCPcsSend = 34;
  1054.       TCPcsNoCopyRcv = 35;
  1055.       TCPcsRcvBfrReturn = 36;
  1056.       TCPcsRcv = 37;
  1057.       TCPcsClose = 38;
  1058.       TCPcsAbort = 39;
  1059.       TCPcsStatus = 40;
  1060.       TCPcsExtendedStat = 41;
  1061.       TCPcsRelease = 42;
  1062.       TCPcsGlobalInfo = 43;
  1063.  
  1064.       UDPcsCreate = 20;
  1065.       UDPcsRead = 21;
  1066.       UDPcsBfrReturn = 22;
  1067.       UDPcsWrite = 23;
  1068.       UDPcsRelease = 24;
  1069.       UDPcsMaxMTUSize = 25;
  1070.       UDPcsStatus = 26;
  1071.       UDPcsMultiCreate = 27;
  1072.       UDPcsMultiSend = 28;
  1073.       UDPcsMultiRead = 29;
  1074.  
  1075.    type
  1076.       TCPEventCode = integer;
  1077.    const
  1078.       TEC_Closing = 1;
  1079.       TEC_ULPTimeout = 2;
  1080.       TEC_Terminate = 3;
  1081.       TEC_DataArrival = 4;
  1082.       TEC_Urgent = 5;
  1083.       TEC_ICMPReceived = 6;
  1084.       TEC_last = 32767;
  1085.  
  1086.    type
  1087.       UDPEventCode = integer;
  1088.    const
  1089.       UDPDataArrival = 1;
  1090.       UDPICMPReceived = 2;
  1091.       lastUDPEvent = 32767;
  1092.  
  1093.    type
  1094.       TCPTerminateReason = integer;
  1095.    const {TCPTerminateReasons: }
  1096.       TTR_RemoteAbort = 2;
  1097.       TTR_NetworkFailure = 3;
  1098.       TTR_SecPrecMismatch = 4;
  1099.       TTR_ULPTimeoutTerminate = 5;
  1100.       TTR_ULPAbort = 6;
  1101.       TTR_ULPClose = 7;
  1102.       TTR_ServiceError = 8;
  1103.       TTR_last = 32767;
  1104.  
  1105.    type
  1106.       ICMPMsgType = integer;
  1107.    const
  1108.       ICMP_NetUnreach = 0;
  1109.       ICMP_HostUnreach = 1;
  1110.       ICMP_ProtocolUnreach = 2;
  1111.       ICMP_PortUnreach = 3;
  1112.       ICMP_FragReqd = 4;
  1113.       ICMP_SourceRouteFailed = 5;
  1114.       ICMP_TimeExceeded = 6;
  1115.       ICMP_ParmProblem = 7;
  1116.       ICMP_MissingOption = 8;
  1117.  
  1118.    type
  1119.       TCPNotifyProc = procPtr;
  1120. { procedure TCPNotifyProc(tcpStream:StreamPtr; event:TCPEventCode;
  1121. userDataPtr:ptr; }
  1122. {                                   terminReason:TCPTerminateReason;
  1123. icmpMsg:ICMPReportPtr); }
  1124.  
  1125.    type
  1126.       TCPIOCompletionProc = procPtr;
  1127. { C procedure TCPIOCompletionProc(iopb:TCPControlBlockPtr); - WHY IS THIS
  1128. A C PROC???? }
  1129.  
  1130.    type
  1131.       UDPNotifyProc = procPtr;
  1132. { procedure UDPProc(udpStream:StreamPtr ;
  1133. eventCode:integer;userDataPtr:ptr; icmpMsg:ICMPReportPtr) }
  1134.  
  1135.    type
  1136.       UDPIOCompletionProc = procPtr;
  1137. { C procedure UDPIOCompletionProc(iopb:UDPiopb Ptr) }
  1138.  
  1139.    type
  1140.       ICMPEchoNotifyProc = ProcPtr;
  1141. { C procedure ICMPEchoNotifyProc(iopb:IPControlBlockPtr) }
  1142. { WARNING: Ignore the docs, its a C proceudre no matter what they say }
  1143.  
  1144.    type
  1145.       ICMPReport = record
  1146.             stream: StreamPtr;
  1147.             localHost: ipAddr;
  1148.             localPort: ipPort;
  1149.             remoteHost: ipAddr;
  1150.             remotePort: ipPort;
  1151.             reportType: ICMPMsgType;
  1152.             optionalAddlInfo: integer;
  1153.             optionalAddlInfoPtr: ptr;
  1154.          end;
  1155.  
  1156.    const
  1157.       NBP_TABLE_SIZE = 20;       { number of NBP table entries }
  1158.       NBP_MAX_NAME_SIZE = 16 + 10 + 2;
  1159.       ARP_TABLE_SIZE = 20;       { number of ARP table entries }
  1160.  
  1161.    type
  1162.       nbpEntry = record
  1163.             ip_address: ipAddr;           { IP address }
  1164.             at_address: longInt;          { matching AppleTalk address }
  1165.             gateway: Boolean;          { TRUE if entry for a gateway }
  1166.             valid: Boolean;               { TRUE if LAP address is valid }
  1167.             probing: Boolean;          { TRUE if NBP lookup pending }
  1168.             age: integer;              { ticks since cache entry verified }
  1169.             access: integer;              { ticks since last access }
  1170.             filler: packed array[1..116] of byte;        { for internal
  1171. use only !!! }
  1172.          end;
  1173.       EnetAddr = record
  1174.             en_hi: integer;
  1175.             en_lo: longInt;
  1176.          end;
  1177.       arpEntry = record
  1178.             age: integer;        { cache aging field }
  1179.             protocol: integer;      { Protocol type }
  1180.             ip_address: ipAddr;     { IP address }
  1181.             en_address: EnetAddr;      { matching Ethernet address }
  1182.          end;
  1183.       AddrXlation = record
  1184.             case integer of
  1185.                0: (
  1186.                      arp_table: ^arpEntry
  1187.                );
  1188.                1: (
  1189.                      nbp_entry: ^nbpEntry
  1190.                )
  1191.          end;
  1192.       LAPStats = record
  1193.             ifType: integer;
  1194.             ifString: CSTRING;
  1195.             ifMaxMTU: integer;
  1196.             ifSpeed: longInt;
  1197.             ifPhyAddrLength: integer;
  1198.             ifPhysicalAddress: CSTRING;
  1199.             addr: AddrXlation;
  1200.             slotNumber: integer;
  1201.          end;
  1202.       IPEchoPB = record
  1203.             dest: ipAddr;           { echo to IP address }
  1204.             data: wdsEntry;
  1205.             timeout: integer;
  1206.             options: Ptr;
  1207.             optLength: integer;
  1208.             icmpCompletion: ICMPEchoNotifyProc;
  1209.             userDataPtr: ptr;
  1210.          end;
  1211.       LAPStatsPB = record
  1212.             lapStatsPtr: ^LAPStats;
  1213.          end;
  1214.       ICMPEchoInfo = record
  1215.             params: array[1..11] of integer;
  1216.             echoRequestOut: longInt;   { time in ticks of when the echo
  1217. request went out }
  1218.             echoReplyIn: longInt;      { time in ticks of when the reply
  1219. was received }
  1220.             data: wdsEntry;      { data received in responce }
  1221.             options: ptr;
  1222.             userDataPtr: ptr;
  1223.          end;
  1224.       IPGetMyIPPB = record
  1225.             ourAddress: ipAddr;        { our IP address }
  1226.             ourNetMask: ipAddr;        { our IP net mask }
  1227.          end;
  1228.  
  1229.       IPControlBlock = record
  1230.             qLink: QElemPtr;
  1231.             qType: INTEGER;
  1232.             ioTrap: INTEGER;
  1233.             ioCmdAddr: Ptr;
  1234.             ioCompletion: TCPIOCompletionProc; {completion routine, or NIL
  1235. if none}
  1236.             ioResult: OSErr; {result code}
  1237.             ioNamePtr: StringPtr;
  1238.             ioVRefNum: INTEGER;
  1239.             ioCRefNum: INTEGER; {device refnum}
  1240.             case csCode : integer of
  1241.                TCPcsGetMyIP: (
  1242.                      getmyip: IPGetMyIPPB;
  1243.                );
  1244.                TCPcsEchoICMP: (
  1245.                      echo: IPEchoPB
  1246.                );
  1247.                9999: (
  1248.                      echoinfo: ICMPEchoInfo
  1249.                );
  1250.                TCPcsLAPStats: (
  1251.                      lapstat: LAPStatsPB
  1252.                );
  1253.          end;
  1254.       IPControlBlockPtr = ^IPControlBlock;
  1255.  
  1256.    type
  1257.       UDPCreatePB = record { for create and release calls }
  1258.             rcvBuff: Ptr;
  1259.             rcvBuffLen: longInt;
  1260.             notifyProc: UDPNotifyProc;
  1261.             localport: ipPort;
  1262.             userDataPtr: ptr;
  1263.             endingPort: ipPort;
  1264.          end;
  1265.  
  1266.    type
  1267.       UDPSendPB = record
  1268.             reserved: integer;
  1269.             remoteIP: ipAddr;
  1270.             remotePort: ipPort;
  1271.             wds: wdsPtr;
  1272.             checkSum: signedByte;
  1273.             sendLength: integer;
  1274.             userDataPtr: ptr;
  1275.             localPort: ipPort;
  1276.          end;
  1277.  
  1278.    type
  1279.       UDPReceivePB = record
  1280.             timeOut: integer;
  1281.             remoteIP: ipAddr;
  1282.             remotePort: ipPort;
  1283.             rcvBuff: ptr;
  1284.             rcvBuffLen: integer;
  1285.             secondTimeStamp: integer;
  1286.             userDataPtr: ptr;
  1287.             destHost: ipAddr;
  1288.             destPort: ipPort;
  1289.          end;
  1290.  
  1291.    type
  1292.       UDPMTUPB = record
  1293.             mtuSize: integer;
  1294.             remoteIP: ipAddr;
  1295.             userDataPtr: ptr;
  1296.          end;
  1297.  
  1298.    type
  1299.       UDPControlBlock = record
  1300.             qLink: QElemPtr;
  1301.             qType: INTEGER;
  1302.             ioTrap: INTEGER;
  1303.             ioCmdAddr: Ptr;
  1304.             ioCompletion: UDPIOCompletionProc;
  1305.             ioResult: OSErr;
  1306.             ioNamePtr: stringPtr;
  1307.             ioVRefNum: integer;
  1308.             ioCRefNum: integer;
  1309.             csCode: integer;
  1310.             udpStream: streamPtr;
  1311.             case integer of
  1312.                UDPcsCreate, UDPcsMultiCreate, UDPcsRelease: (
  1313.                      create: UDPCreatePB
  1314.                );
  1315.                UDPcsWrite, UDPcsMultiSend: (
  1316.                      send: UDPSendPB
  1317.                );
  1318.                UDPcsRead, UDPcsMultiRead: (
  1319.                      receive: UDPReceivePB
  1320.                );
  1321.                UDPcsBfrReturn: (
  1322.                      return: UDPReceivePB
  1323.                );
  1324.                UDPcsMaxMTUSize: (
  1325.                      mtu: UDPMTUPB
  1326.                );
  1327.          end;
  1328.       UDPControlBlockPtr = ^UDPControlBlock;
  1329.  
  1330.    const { Validity Flags }
  1331.       timeOutValue = $80;
  1332.       timeOutAction = $40;
  1333.       typeOfService = $20;
  1334.       precedence = $10;
  1335.  
  1336.    const { TOSFlags }
  1337.       lowDelay = $01;
  1338.       throughPut = $02;
  1339.       reliability = $04;
  1340.  
  1341.    type
  1342.       TCPCreatePB = packed record
  1343.             rcvBuff: ptr;
  1344.             rcvBuffLen: longInt;
  1345.             notifyProc: TCPNotifyProc;
  1346.             userDataPtr: ptr;
  1347.          end;
  1348.  
  1349.       TCPOpenPB = packed record
  1350.             ulpTimeoutValue: byte;
  1351.             ulpTimeoutAction: signedByte;
  1352.             validityFlags: byte;
  1353.             commandTimeoutValue: byte;
  1354.             remoteHost: ipAddr;
  1355.             remotePort: ipPort;
  1356.             localHost: ipAddr;
  1357.             localPort: ipPort;
  1358.             tosFlags: byte;
  1359.             precedence: byte;
  1360.             dontFrag: C_BOOLEAN;
  1361.             timeToLive: byte;
  1362.             security: byte;
  1363.             optionCnt: byte;
  1364.             options: array[0..39] of byte;
  1365.             userDataPtr: ptr;
  1366.          end;
  1367.  
  1368.       TCPSendPB = packed record
  1369.             ulpTimeoutValue: byte;
  1370.             ulpTimeoutAction: signedByte;
  1371.             validityFlags: byte;
  1372.             pushFlag: byte;
  1373.             urgentFlag: C_BOOLEAN;
  1374.             wds: wdsptr;
  1375.             sendFree: longInt;
  1376.             sendLength: integer;
  1377.             userDataPtr: ptr;
  1378.          end;
  1379.  
  1380.       TCPReceivePB = packed record
  1381.             commandTimeoutValue: byte;
  1382.             filler: byte;
  1383.             markFlag: C_BOOLEAN;
  1384.             urgentFlag: C_BOOLEAN;
  1385.             rcvBuff: ptr;
  1386.             rcvBuffLength: integer;
  1387.             rdsPtr: ptr;
  1388.             rdsLength: integer;
  1389.             secondTimeStamp: integer;
  1390.             userDataPtr: ptr;
  1391.          end;
  1392.  
  1393.       TCPClosePB = packed record
  1394.             ulpTimeoutValue: byte;
  1395.             ulpTimeoutAction: signedByte;
  1396.             validityFlags: byte;
  1397.             userDataPtrX: ptr;   { Thats mad!  Its not on a word boundary!
  1398. Parhaps a documentation bug??? }
  1399.          end;
  1400.  
  1401.       HistoBucket = packed record
  1402.             value: integer;
  1403.             counter: longInt;
  1404.          end;
  1405.  
  1406.    const
  1407.       NumOfHistoBuckets = 7;
  1408.  
  1409.    type
  1410.       TCPConnectionStats = packed record
  1411.             dataPktsRcvd: longInt;
  1412.             dataPktsSent: longInt;
  1413.             dataPktsResent: longInt;
  1414.             bytesRcvd: longInt;
  1415.             bytesRcvdDup: longInt;
  1416.             bytesRcvdPastWindow: longInt;
  1417.             bytesSent: longInt;
  1418.             bytesResent: longInt;
  1419.             numHistoBuckets: integer;
  1420.             sentSizeHisto: array[1..NumOfHistoBuckets] of HistoBucket;
  1421.             lastRTT: integer;
  1422.             tmrRTT: integer;
  1423.             rttVariance: integer;
  1424.             tmrRTO: integer;
  1425.             sendTries: byte;
  1426.             sourceQuenchRcvd: byte;
  1427.          end;
  1428.       TCPConnectionStatsPtr = ^TCPConnectionStats;
  1429.  
  1430.       TCPStatusPB = packed record
  1431.             ulpTimeoutValue: byte;
  1432.             ulpTimeoutAction: signedByte;
  1433.             unused: longInt;
  1434.             remoteHost: ipAddr;
  1435.             remotePort: ipPort;
  1436.             localHost: ipAddr;
  1437.             localPort: ipPort;
  1438.             tosFlags: byte;
  1439.             precedence: byte;
  1440.             connectionState: byte;
  1441.             filler: byte;
  1442.             sendWindow: integer;
  1443.             rcvWindow: integer;
  1444.             amtUnackedData: integer;
  1445.             amtUnreadData: integer;
  1446.             securityLevelPtr: ptr;
  1447.             sendUnacked: longInt;
  1448.             sendNext: longInt;
  1449.             congestionWindow: longInt;
  1450.             rcvNext: longInt;
  1451.             srtt: longInt;
  1452.             lastRTT: longInt;
  1453.             sendMaxSegSize: longInt;
  1454.             connStatPtr: TCPConnectionStatsPtr;
  1455.             userDataPtr: ptr;
  1456.          end;
  1457.  
  1458.       TCPAbortPB = packed record
  1459.             userDataPtr: ptr;
  1460.          end;
  1461.  
  1462.       TCPParam = packed record
  1463.             tcpRTOA: StringPtr;
  1464.             tcpRTOMin: longInt;
  1465.             tcpRTOMax: longInt;
  1466.             tcpMaxSegSize: longInt;
  1467.             tcpMaxConn: longInt;
  1468.             tcpMaxWindow: longInt;
  1469.          end;
  1470.       TCPParamPtr = ^TCPParam;
  1471.  
  1472.       TCPStats = packed record
  1473.             tcpConnAttempts: longInt;
  1474.             tcpConnOpened: longInt;
  1475.             tcpConnAccepted: longInt;
  1476.             tcpConnClosed: longInt;
  1477.             tcpConnAborted: longInt;
  1478.             tcpOctetsIn: longInt;
  1479.             tcpOctetsOut: longInt;
  1480.             tcpOctetsInDup: longInt;
  1481.             tcpOctetsRetrans: longInt;
  1482.             tcpInputPackets: longInt;
  1483.             tcpOutputPkts: longInt;
  1484.             tcpDupPkts: longInt;
  1485.             tcpRetransPkts: longInt;
  1486.          end;
  1487.       TCPStatsPtr = ^TCPStats;
  1488.  
  1489.       StreamPtrArray = array[1..1000] of StreamPtr;
  1490.       StreamPtrArrayPtr = ^StreamPtrArray;
  1491.  
  1492.       TCPGlobalInfoPB = packed record
  1493.             tcpParamp: TCPParamPtr;
  1494.             tcpStatsp: TCPStatsPtr;
  1495.             tcpCDBTable: StreamPtrArrayPtr;
  1496.             userDataPtr: ptr;
  1497.             maxTCPConnections: integer;
  1498.          end;
  1499.  
  1500.       TCPControlBlock = record
  1501.             qLink: QElemPtr;
  1502.             qType: INTEGER;
  1503.             ioTrap: INTEGER;
  1504.             ioCmdAddr: Ptr;
  1505.             ioCompletion: TCPIOCompletionProc; {completion routine, or NIL
  1506. if none}
  1507.             ioResult: OSErr; {result code}
  1508.             ioNamePtr: StringPtr;
  1509.             ioVRefNum: INTEGER;
  1510.             ioCRefNum: INTEGER; {device refnum}
  1511.             csCode: integer;
  1512.             tcpStream: StreamPtr;
  1513.             case integer of
  1514.                TCPcsCreate: (
  1515.                      create: TCPCreatePB
  1516.                );
  1517.                TCPcsActiveOpen, TCPcsPassiveOpen: (
  1518.                      open: TCPOpenPB;
  1519.                );
  1520.                TCPcsSend: (
  1521.                      send: TCPSendPB;
  1522.                );
  1523.                TCPcsNoCopyRcv, TCPcsRcvBfrReturn, TCPcsRcv: (
  1524.                      receive: TCPReceivePB;
  1525.                );
  1526.                TCPcsClose: (
  1527.                      close: TCPClosePB;
  1528.                );
  1529.                TCPcsAbort: (
  1530.                      abort: TCPAbortPB;
  1531.                );
  1532.                TCPcsStatus: (
  1533.                      status: TCPStatusPB;
  1534.                );
  1535.                TCPcsGlobalInfo: (
  1536.                      globalInfo: TCPGlobalInfoPB
  1537.                );
  1538.          end;
  1539.       TCPControlBlockPtr = ^TCPControlBlock;
  1540.  
  1541. implementation
  1542.  
  1543. end.
  1544. -- 
  1545. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  1546. FTP my programs from redback.cs.uwa.edu.au:Others/PeterLewis/ or
  1547. amug.org:pub/peterlewis/ or nic.switch.ch:software/mac/peterlewis/
  1548.  
  1549. ---------------------------
  1550.  
  1551. >From woody@alumni.caltech.edu (William Edward Woody)
  1552. Subject: Is there a reasonable alternative to BalloonWriter?
  1553. Date: 13 Sep 1994 05:13:29 GMT
  1554. Organization: California Institute of Technology, Alumni Association
  1555.  
  1556.  
  1557. Pretty much what the subject line says.
  1558.  
  1559. Thus far I'm aware of three ways to write balloon help.
  1560. First, there's writing a resource script and compile that
  1561. with MPW's rez; and while that's marginally okay, (1) rez
  1562. cannot be compiled inside of CW (I have to use the toolserver),
  1563. and (2) rez scripts are a pain if the person who is writing
  1564. them is not a Macintosh programmer.
  1565.  
  1566. The second way is to use BalloonWriter. That'd be okay,
  1567. except the existing one is buggier than hell, won't even
  1568. run on a Quadra, and Apple seemed to have dropped it like
  1569. a hot potato.
  1570.  
  1571. The third way is apparently through Resourcerer. And
  1572. somehow I don't see paying $300 when for 99% of the
  1573. resources, I'm perfectly happy with ResEdit.
  1574.  
  1575. Is there another alternative I'm not aware of?
  1576.  
  1577. Or will Apple bother to finish BalloonWriter and at least
  1578. fix the bugs that prevent it from running on my Quadra 700?
  1579.  
  1580.                         - Bill
  1581. -- 
  1582. o William Edward Woody      | "I'm shying from the light
  1583.   In Phase Consulting      |  I always loved the night
  1584.   337 West California #4  |  And now you offer me eternal darkness"
  1585.   Glendale, CA 91203      |          - Depeche Mode, "One Caress"
  1586.  
  1587. +++++++++++++++++++++++++++
  1588.  
  1589. >From oster@netcom.com (David Phillip Oster)
  1590. Date: Tue, 13 Sep 1994 17:14:43 GMT
  1591. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  1592.  
  1593.  
  1594. I don't like BalloonWriter, because it puts the help text in the body
  1595. of the 'hmnu' and 'hdlg' resources, and since there is so much repetition,
  1596. it is better to indirect from the 'hmnu' and 'hdlg' resources to STR#s,
  1597. so you can just reference multiple instances of the same string.
  1598.  
  1599. I've written a program, called Balloony that works as follows:
  1600. you drop the application on to it. It makes a applicationHelp.r file that
  1601. contains 'hmnu' and 'hdlg' resources for all menus and dialogs, indirected
  1602. to dummy STR#s that are initialized with the menu text and the DITL text.
  1603. if you use CNTL resources, it indirects through to them and puts their title
  1604. string in the STR#. If there is no title, it uses a generic string like:
  1605. "icon" or "pict".  Having the help text in STR#s makes internationalization
  1606. easier.
  1607.  
  1608. I will license a single user copy to you for $20.00, if you are interested,
  1609. or you can always write your own.
  1610. -- 
  1611. - ------- oster@netcom.com ----------
  1612. "Wendy, you were born a ninja princess, but you were kidnapped by a
  1613. band of tax accountants who raised you as their own." -- Ninja C.P.A.
  1614.  
  1615. +++++++++++++++++++++++++++
  1616.  
  1617. >From Paul Ferguson <pferguson@kaleida.com>
  1618. Date: 14 Sep 1994 20:38:12 GMT
  1619. Organization: Kaleida Labs, Inc.
  1620.  
  1621. In article <osterCw2vwK.7x4@netcom.com> David Phillip Oster, oster@netcom.com
  1622. writes:
  1623. > [... Balloony ...]
  1624. > I will license a single user copy to you for $20.00, if you are interested,
  1625. > or you can always write your own.
  1626.  
  1627. Why not release it as shareware?  It sounds like a handy little
  1628. utility.
  1629.  
  1630. --fergy
  1631.  
  1632. - ------------------------------------------------------------------
  1633.   Paul Ferguson         | "It's a sick world, I'm a happy guy..."
  1634.   pferguson@kaleida.com |  
  1635. - ------------------------------------------------------------------
  1636.  
  1637. +++++++++++++++++++++++++++
  1638.  
  1639. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  1640. Date: Fri, 16 Sep 1994 14:54:29 +0800
  1641. Organization: NCRPDA, Curtin University
  1642.  
  1643. In article <353cdp$7h3@gap.cco.caltech.edu>, woody@alumni.caltech.edu
  1644. (William Edward Woody) wrote:
  1645.  
  1646.  
  1647. >Thus far I'm aware of three ways to write balloon help.
  1648. >First, there's writing a resource script and compile that
  1649. >with MPW's rez; and while that's marginally okay, (1) rez
  1650. >cannot be compiled inside of CW (I have to use the toolserver),
  1651. >and (2) rez scripts are a pain if the person who is writing
  1652. >them is not a Macintosh programmer.
  1653.  
  1654. This can be simplified a fair bit using Perl to parse a high level
  1655. format.  This is what I do, and it automates most of the process.
  1656.  
  1657. **** High level balloon help data for Anarchie
  1658. DIALOG 200 Archie
  1659.  
  1660. 1.1 Click this to begin the search.
  1661.  
  1662. 2.1 Click this to close the window without starting a search.
  1663.  
  1664. 4.1 Click this to save this query into a bookmark document.
  1665.  
  1666. 5.3 Use this popup menu to select a server from a list of common servers.
  1667. 5.4 Use this popup menu to select a server from a list of common servers.
  1668.  
  1669. 6.1 Type the name of the Archie server to query here. Alternatively you
  1670. can select a server from the popup menu.
  1671.  
  1672. 7.1 Type the text of your query here.
  1673.  
  1674. 8.1 Click this to use a sub-string matching query.
  1675. 8.3 The query will be a simple sub-string match. It will return any entry
  1676. whose name contains the Find string.
  1677. 9.1 Click this to use a pattern matching query.
  1678. 9.3 The Find string is interpreted as a pattern and the query returns
  1679. entries that match the pattern. * matches any sequences of characters, ?
  1680. matches any single character.
  1681. 10.1 Click this to use a regular expression matching query.
  1682. 10.3 The Find string is interpreted as a regular expression and the query
  1683. returns entries that match the regex. Regexes are too complicated to
  1684. explain here.
  1685.  
  1686. 11.1 The query will be case-insensitive, thus ≥Frog≤, ≥frog≤ and ≥FROG≤
  1687. will be considered the same.
  1688. 11.3 The query will be case-sensitive, thus ≥frog≤ and ≥FROG≤ will be
  1689. considered different.
  1690.  
  1691. 12.1 Type the maximum number of matching entries to be returned by the
  1692. query here.
  1693.  
  1694. END-DIALOG
  1695.  
  1696. DIALOG 500 Preferences Dialog
  1697.  
  1698. 1.1 Click this to save the preferences.
  1699.  
  1700. 2.1 Click this to discard any changes you have made since you last saved
  1701. the preferences.
  1702.  
  1703. 4.1 Type your Email address here. This address is used as the password
  1704. when you log into anonymous FTP servers.
  1705.  
  1706. 5.1 Type the name of your prefered Info-Mac mirror site (host:path
  1707. format). Alternatively you can select a server from the popup menu.
  1708.  
  1709. 6.3 Use this popup menu to select an Info-Mac mirror from a list of mirrors.
  1710. 6.4 Use this popup menu to select an Info-Mac mirror from a list of mirrors.
  1711.  
  1712. 7.1 Type the name of your prefered UMich mirror site (host:path format).
  1713. Alternatively you can select a server from the popup menu.
  1714.  
  1715. 8.3 Use this popup menu to select an UMich mirror from a list of mirrors.
  1716. 8.4 Use this popup menu to select an UMich mirror from a list of mirrors.
  1717.  
  1718. 9.3 Select the face of the font you wish to use in new windows.
  1719. 9.4 Select the face of the font you wish to use new windows.
  1720.  
  1721. 10.1 Type the size (in points) of the font you wish to use in new windows here.
  1722.  
  1723. 11.1 Anarchie will not open a blank Find window when it is launched.
  1724. 11.3 Anarchie will open a blank Find window when it is launched.
  1725.  
  1726. 12.1 Anarchie will not open the bookmark listing window when it is launched.
  1727. 12.3 Anarchie will open the bookmark listing window when it is launched.
  1728.  
  1729. 13.1 Click this to specify the folder in which to place downloaded files.
  1730.  
  1731. 14.1 Anarchie will not decode fetched files.
  1732. 14.3 Anarchie will use StuffIt Expander to decode fetched files.
  1733.  
  1734. 15.1 Click here to use normal FTP when transferring files.
  1735. 15.3 Normal (anonymous) FTP will be used when transferring files.
  1736. 16.1 Click here to use the specified Alex server when transferring files.
  1737. 16.3 The specified Alex server will be used when transferring files.
  1738. 17.1 Click here to use the specified proxy firewall when transferring files.
  1739. 17.3 The specified firewall will be used when transferring files.
  1740. 18.1 Click here to use the specified SOCKS firewall when transferring files.
  1741. 18.3 The specified SOCKS firewall will be used when transferring files.
  1742.  
  1743. 19.1 Type the address of your preferred Alex server here.
  1744.  
  1745. 20.1 Type the address of your personal, very own, favourite proxy firewall
  1746. server here.
  1747.  
  1748. 21.1 Type the address of your personal, very own, favourite SOCKS firewall
  1749. server here.
  1750.  
  1751. 22.1 This displays the country code of the country in which Anarchie
  1752. thinks you are located. Anarchie uses this to calculate the distance value
  1753. in listing windows.
  1754. 22.2 This displays the country code of the country in which Anarchie
  1755. thinks you are located. Anarchie uses this to calculate the distance value
  1756. in listing windows.
  1757.  
  1758. 23.1 You have not paid for this copy of ≥Anarchie≤.
  1759. 23.3 You have paid for this copy of ≥Anarchie≤. Thanks!!!
  1760.  
  1761. END-DIALOG
  1762.  
  1763. DIALOG 600 FTP
  1764.  
  1765. 1.1 Click this button to fetch the file or listing.
  1766. 1.2 This buttons fetches the specified file or listing. Not available
  1767. because you have not specified a valid host and path, or you donπt have
  1768. enough free memory.
  1769.  
  1770. 2.1 Click this button to close the window without fetching a file or listing.
  1771.  
  1772. 4.1 Click this button to save this fetch command into a bookmark document.
  1773. 4.2 This button saves this fetch command into a bookmark document. Not
  1774. available because you have not specified a valid host and path.
  1775.  
  1776. 5.1 Type a host name here eg ≥redback.cs.uwa.edu.au≤.
  1777. 6.1 Type a path here eg ≥/ComSci/ReadMeAboutRedback≤.
  1778. 7.1 Type a username here eg ≥fred≤.  Leave the field blank for anonymous FTP.
  1779. 8.1 Type a password here eg ≥oihhlkhu≤.  Leave the field blank for
  1780. anonymous FTP.  Characters will be displayed as ≥Ä≤.
  1781.  
  1782. 9.1 Click here if the path leads to a directory. command-1 is a shortcut
  1783. for this.
  1784. 9.3 The specified path should lead to directory. If the path leads to file
  1785. then you will get a listing window with just that file in it.
  1786. 10.1 Click here if the path leads to a file. command-2 is a shortcut for this.
  1787. 10.3 The specified path should lead to a file. If the path leads to a
  1788. directory then you will get an error.
  1789. 11.1 Click here if the path leads to a text file you wish to view.
  1790. command-3 is a shortcut for this.
  1791. 11.3 The specified path should lead to a text file. If the path leads to a
  1792. directory then you will get an error.
  1793. 12.1 Click here to try indexing the ftp site (type a search string into
  1794. the second field). command-4 is a shortcut for this.
  1795. 12.3 The specified index string will be used to search the ftp site (if it
  1796. supports SITE INDEX).
  1797.  
  1798. END-DIALOG
  1799.  
  1800. DIALOG 2004 Find
  1801.  
  1802. 1.1 Click this button to find an entry in the listing.
  1803.  
  1804. 2.1 Click this button to close the window without finding anything.
  1805.  
  1806. 4.1 Type in the text to search for.
  1807.  
  1808. 5.1 Only the first entry will be found.
  1809. 5.3 All matching entries swill be selected.
  1810.  
  1811. END-DIALOG
  1812.  
  1813. MENU 129 File
  1814.  
  1815. 0 xxxx,,,File
  1816. 1 Use this menu to search for files, retrieve files, save bookmarks and
  1817. save listings.
  1818.  
  1819. 0 arch,T,,Archieä
  1820. 1 Search for a file by querying an Archie server.
  1821. 2 Search for a file. Not available because there is already a Search
  1822. window open.
  1823.  
  1824. 0 fget,E,,Getä
  1825. 1 Get a file or listing from an FTP site. You must enter the host name and
  1826. path of the file
  1827. 2 Get a file from an FTP site. Not available because there is not enough
  1828. free memory.
  1829.  
  1830. 0 gets,,,Get Selection
  1831. 1 Get the selected file or listing from an FTP site. The ≥return≤ key is
  1832. often a shortcut for this command.
  1833. 2 Get the selected file or listing. Not available because there is nothing
  1834. selected.
  1835.  
  1836. 0 view,L,,View Selection
  1837. 1 View the selected file in your favourite text editor. This is also
  1838. useful for getting text files.
  1839. 2 View the selected file. Not available because there is nothing selected.
  1840.  
  1841. 0 rtry,R,,Retry
  1842. 1 Retry a failed ≥Get≤ or ≥Archie≤ operation. Hold down the option key to
  1843. edit the request before retrying.
  1844. 2 Retry a failed operation. Not available because the current window
  1845. cannot be retried.
  1846.  
  1847. 0 obok,O,,Open Bookmarkä
  1848. 1 Open a saved bookmark file and fetch the results. Hold down the option
  1849. key to edit the request before acting on it.
  1850. 2 Open a saved bookmark file. Not available because there is not enough
  1851. free memory.
  1852.  
  1853. 0 obms,B,,List Bookmarksä
  1854. 1 Open a window listing all the bookmarks in the Bookmarks folder.
  1855. 2 Open the bookmarks window. Not available because there is not enough
  1856. free memory.
  1857.  
  1858. 0
  1859.  
  1860. 0 sbok,S,,Save Bookmarkä
  1861. 1 Save a bookmark (or bookmark list) for later use. The bookmark refers to
  1862. either the current selection or, if there is no selection, the front
  1863. window.
  1864. 2 Save a bookmark (or bookmark list) for the front window. Not available
  1865. because the front window does not support bookmarks.
  1866.  
  1867. 0 svls,,,Save Listingä
  1868. 1 Save the front window to a text file which you can import into a
  1869. spreadsheet or word processor.
  1870. 2 Save the front window to a text file. Not available because the front
  1871. window does not support listings.
  1872.  
  1873. 0 clos,W,,Close
  1874. 1 Close the front window. Hold down the option key to close all windows.
  1875. 2 Not available because there is no window to close.
  1876.  
  1877. 0
  1878.  
  1879. 0 help,H,,Helpä
  1880. 1 Display the help window.
  1881.  
  1882. 0
  1883.  
  1884. 0 quit,Q,,Quit
  1885. 1 Quit ≥Anarchie≤.
  1886.  
  1887. END-MENU
  1888.  
  1889. MENU 130 Edit
  1890.  
  1891. 0 xxxx,,,Edit
  1892. 1 Use this menu to work with text or to set preferences.
  1893.  
  1894. 0 undo,Z,,Undo
  1895. 1 Undoes the previous text command.
  1896. 2 Not available because the last operation cannot be undone.
  1897.  
  1898. 0
  1899.  
  1900. 0 cut ,X,,Cut
  1901. 1 Cuts or removes the selected text. The text is put into the clipboard.
  1902. 2 Not available because no text is selected.
  1903.  
  1904. 0 copy,C,,Copy
  1905. 1 Copies the selected item into the clipboard.  With the option key down,
  1906. this will often copy as a URL.
  1907. 2 Not available because nothing is selected.
  1908.  
  1909. 0 past,V,,Paste
  1910. 1 Puts the current contents of the clipboard into the current selection.
  1911. 2 Not available because nothing appropriate is in the clipboard or because
  1912. you canπt paste anything into the current selection.
  1913.  
  1914. 0 clea,,,Clear
  1915. 1 Remove the selected text or delete log entries. The text is lost forever.
  1916. 2 Removes the selected text. Not available because nothing that can be
  1917. deleted is selected.
  1918.  
  1919. 0 sela,A,,Select All
  1920. 1 Select the entire contents of the front window.
  1921. 2 Not available because you canπt select anything in the front window or
  1922. because you already have selected everything.
  1923.  
  1924. 0
  1925.  
  1926. 0 find,F,,Findä
  1927. 1 Find a matching entry in the window.
  1928. 2 Not available because the front window is not a List Window.
  1929.  
  1930. 0 fagn,G,,Find Again
  1931. 1 Find the next matching entry.
  1932. 2 Not available because the front window is not a List Window.
  1933.  
  1934. 0
  1935.  
  1936. 0 ftch,,,Fetch Server List
  1937. 1 Fetch the definitive server list from an FTP site in Texas.
  1938. 2 Not available because there is not enough free memory.
  1939.  
  1940. 0 pref,,,Preferencesä
  1941. 1 Modify the preferences.
  1942. 2 Not available because the preferences window is already at the front.
  1943.  
  1944. END-MENU
  1945.  
  1946. MENU 150 Window
  1947.  
  1948. 0 xxxx,,,Window
  1949. 1 Use this menu to bring a window to the front.
  1950.  
  1951. 0 logw,,,Show Log
  1952. 1 Display the Log Window.
  1953. 2 Not available because the log window is already at the front.
  1954.  
  1955. 0 tran,,,Show Transcript
  1956. 1 Display the Transcript Window.
  1957. 2 Not available because the transcript window is already at the front.
  1958.  
  1959. END-MENU
  1960.  
  1961. END
  1962.  
  1963. (evaluate "{active}" =~ /(â)Æ1:â/ )> dev:null
  1964. directory "{Æ1}"
  1965. Perl.68k -Sx "Rocky:Peter:Perl:Balloons.pl"
  1966. rez -a -o "Anarchie.rsrc" -ov Balloons.r
  1967. delete Balloons.r
  1968. *****
  1969.  
  1970. Just change the path for Balloons.pl to point to the following file, and
  1971. change Anarchie.rsrc to be your resource file (make a copy first to be
  1972. safe).  Then edit the high level file in MPW, and select those last few
  1973. lines to update the .rsrc file.
  1974.  
  1975. ***** Balloons.pl *****
  1976. #!perl
  1977.  
  1978. $balloons_strh_id = 26724;
  1979.  
  1980. # chdir "Rocky:Peter:Pascal:TCP Work:TCP Programs:Anarchie";
  1981.  
  1982. open(STDIN,"Balloons Data") || die "Failed to open input";
  1983. open(STDOUT,">Balloons.r") || die "Failed to open output";
  1984.  
  1985. print <<INCLUDES;
  1986. #include "Types.r"
  1987. #include "BalloonTypes.r"
  1988.  
  1989. INCLUDES
  1990.  
  1991. @strings=();
  1992.  
  1993. while (<>) {
  1994.   chop;
  1995.   next if /^$/;
  1996.   last if /^END$/;
  1997.   die "Bad line '$_'" unless /(DIALOG|MENU)\s+(\d+)\s*(.*)/;
  1998.   $dialog = $1 eq "DIALOG"; $id = $2; $name=$3;
  1999.   @items=();
  2000.    @menus=();
  2001.    $menuitem=0;
  2002.   while (<>) {
  2003.     chop;
  2004.     next if /^$/;
  2005.     if ($dialog) {
  2006.        last if /^END-DIALOG$/;
  2007.        die "Bad dialog line '$_'" unless /^(\d+)\.(\d+)\s+(.*)/;
  2008.        die "Quote in line" if /"/;
  2009.        $base=($1-1)*4;
  2010.        $item=$base+$2-1;
  2011.        $index = &find_string($3);
  2012.        $items[$item] = $index;
  2013.        $items[$base+0] = 0 unless $items[$base+0];
  2014.        $items[$base+1] = 0 unless $items[$base+1];
  2015.        $items[$base+2] = 0 unless $items[$base+2];
  2016.        $items[$base+3] = 0 unless $items[$base+3];
  2017.     } else {
  2018.        last if /^END-MENU$/;
  2019.        die "Quote in line '$_'" if /"/;
  2020.        die "Bad menu line '$_'" unless /^(\d) (.*)/ || /^(\d)$/;
  2021.          if ($1 == 0) {
  2022.            if ($1 eq $_) {
  2023.              $menus[$menuitem]='-';
  2024.             } else {
  2025.               $menus[$menuitem]= $2;
  2026.             }
  2027.             $menuitem++;
  2028.          } else {
  2029.             $base=($menuitem-1)*4;
  2030.             $item=$base+$1-1;
  2031.             $index = &find_string($2);
  2032.             $items[$item] = $index;
  2033.             $items[$base+0] = 0 unless $items[$base+0];
  2034.             $items[$base+1] = 0 unless $items[$base+1];
  2035.             $items[$base+2] = 0 unless $items[$base+2];
  2036.             $items[$base+3] = 0 unless $items[$base+3];
  2037.          }
  2038.     }
  2039.   }
  2040.    if ($dialog) {
  2041.    print <<"HEADER";
  2042. resource 'hdlg' ($id,"$name") {
  2043. \t2,0,0,0,0,
  2044. \tHMSkipItem { },
  2045. \t{
  2046. HEADER
  2047.    } else {
  2048.       print <<"HEADER";
  2049. resource 'hmnu' ($id,"$name") {
  2050. \t2,0,0,0,
  2051. \tHMSkipItem { },
  2052. \t{
  2053. HEADER
  2054.    }
  2055.   for $item (1..@items/4) {
  2056.     $base = ($item-1)*4;
  2057.     if ($items[$base+0] || $items[$base+1] ||
  2058.         $items[$base+2] || $items[$base+3]) {
  2059.          print "\t\tHMStringResItem { /* $item */\n";
  2060.          if ($dialog) {
  2061.          print <<"ITEM";
  2062. \t\t\t{0,0},
  2063. \t\t\t{0,0,0,0},
  2064. ITEM
  2065.          }
  2066.       for $k (0..3) {
  2067.         $index = $items[$base+$k];
  2068.         if ($index) {
  2069.           print "\t\t\t$balloons_strh_id,$index,\n";
  2070.         } else {
  2071.           print "\t\t\t0,0,\n";
  2072.         }
  2073.       }
  2074.       print "\t\t},\n";
  2075.     } else {
  2076.         print "\t\tHMSkipItem { }, /* $item */\n";
  2077.     }
  2078.   }
  2079.   print <<"TRAILER";
  2080. \t}
  2081. };
  2082.  
  2083. TRAILER
  2084. }
  2085.  
  2086. print "resource 'STR#' ($balloons_strh_id,\"Balloon Help Strings\") {\n";
  2087. print "\t{\n";
  2088. for $index (1..@strings) {
  2089.   print "\t\t/* $index */\n";
  2090.   print "\t\t\"$strings[$index-1]\",\n";
  2091. }
  2092. print "\t}\n";
  2093. print "};\n\n";
  2094.  
  2095. close(STDOUT);
  2096. close(STDIN);
  2097.  
  2098. sub find_string {
  2099.   local($s) = @_;
  2100.   local($i);
  2101.   for $i (1..@strings) {
  2102.     return $i if $s eq $strings[$i-1];
  2103.   }
  2104.   $i = @strings;
  2105.   $strings[$i] = $s;
  2106.   return $i+1;
  2107. }
  2108. *****
  2109.  
  2110. Enjoy,
  2111.    Peter.
  2112. -- 
  2113. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  2114. FTP my programs from redback.cs.uwa.edu.au:Others/PeterLewis/ or
  2115. amug.org:pub/peterlewis/ or nic.switch.ch:software/mac/peterlewis/
  2116.  
  2117. ---------------------------
  2118.  
  2119. >From chrisat@ids.net (Chris Arsenault)
  2120. Subject: Need help with MDEF UPP Question
  2121. Date: 16 Sep 1994 11:26:48 GMT
  2122. Organization: Sandcastle Studios
  2123.  
  2124. I'm in the process of converting a 68k C application over to PowerPC and
  2125. ran into a snag. There's a menu def proc module that resides in the main
  2126. 68k code segment and is patched in via the code resource stub trick. This
  2127. trick doesn't work too well on the PowerPC. 
  2128.  
  2129. I thought I could still keep the MDEF module in with the application
  2130. rather than as a standalone code resource, by installing a MenuDefUPP in
  2131. the (**myMenuHandle).menuDefProc. I figured this approach would handle
  2132. either PPC or 68k and would remove the self-modifying code.   The PowerPC
  2133. version isn't working.  It keeps crashing into _MoveHLow.
  2134.  
  2135. I'd really like to keep the menudef proc in the application as it uses
  2136. globals etc.
  2137.  
  2138. Is this the right approach or is there another way to do this?  Any help
  2139. would be greatly appreciated.
  2140.  
  2141.  
  2142. Chris
  2143.  
  2144. +++++++++++++++++++++++++++
  2145.  
  2146. >From duga@pacersoft.com (Brady Duga)
  2147. Date: Fri, 16 Sep 1994 09:28:21 -0500
  2148. Organization: Pacer Software, Inc.
  2149.  
  2150. In article <chrisat-1609940719040001@pslip092.egr-ri.ids.net>,
  2151. chrisat@ids.net (Chris Arsenault) wrote:
  2152.  
  2153. > I thought I could still keep the MDEF module in with the application
  2154. > rather than as a standalone code resource, by installing a MenuDefUPP in
  2155. > the (**myMenuHandle).menuDefProc. I figured this approach would handle
  2156. > either PPC or 68k and would remove the self-modifying code.   The PowerPC
  2157. > version isn't working.  It keeps crashing into _MoveHLow.
  2158.  
  2159. In your MDEF stub, how are you calling the UPP? Remember, you can't just
  2160. call it like a function, you have to use CallUniversalProc(). For an MDEF,
  2161. you would use:
  2162.  
  2163. CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2);
  2164.  
  2165. That's #defined in Menus.h.
  2166.  
  2167.  
  2168. --Brady
  2169.  
  2170. +++++++++++++++++++++++++++
  2171.  
  2172. >From sbill@informix.com (Bill Stackhouse)
  2173. Date: 16 Sep 1994 16:39:00 GMT
  2174. Organization: Informix Software, Inc.
  2175.  
  2176. In article <chrisat-1609940719040001@pslip092.egr-ri.ids.net> chrisat@ids.net (Chris Arsenault) writes:
  2177. >I'm in the process of converting a 68k C application over to PowerPC and
  2178. >ran into a snag. There's a menu def proc module that resides in the main
  2179. >68k code segment and is patched in via the code resource stub trick. This
  2180. >trick doesn't work too well on the PowerPC. 
  2181. >
  2182. >I thought I could still keep the MDEF module in with the application
  2183. >rather than as a standalone code resource, by installing a MenuDefUPP in
  2184. >the (**myMenuHandle).menuDefProc. I figured this approach would handle
  2185. >either PPC or 68k and would remove the self-modifying code.   The PowerPC
  2186. >version isn't working.  It keeps crashing into _MoveHLow.
  2187.  
  2188. Just went through the same problem. Here is the pseudo code:
  2189.  
  2190. #if powerpc
  2191. create handle size of UPP
  2192. create UPP
  2193. copy in the UPP
  2194. store handle in menuProc
  2195. destroy UPP
  2196. #else
  2197. create handle size 6 bytes
  2198. copy in jmp MDEF
  2199. store handle in menuProc
  2200. #endif
  2201.  
  2202.  
  2203. Bill
  2204.  
  2205. ---------------------------
  2206.  
  2207. >From boyerr@bach.seattleu.edu (Robert A. Boyer)
  2208. Subject: OpenDoc Development Environments?
  2209. Date: 18 Sep 1994 12:28:50 -0700
  2210. Organization: Seattle University, Seattle, WA, USA
  2211.  
  2212. Does anyone have experience developing OpenDoc applications on a
  2213. Macintosh using a development environment other than MPW?  What
  2214. are the pros and cons of the following C++ development environments:
  2215. MPW, Symantec, and Metroworks?
  2216.  
  2217. Thanks,
  2218.  
  2219. Robert Boyer
  2220. boyerr@seattleu.edu
  2221.  
  2222. +++++++++++++++++++++++++++
  2223.  
  2224. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  2225. Date: Tue, 20 Sep 1994 00:10:43 GMT
  2226. Organization: Apple Computer
  2227.  
  2228. The current status is that you need cfront or scpp (the Symantec MPW tool) to
  2229. build OpenDoc A6 shared libraries. If you get the OpenDoc source code CD,
  2230. there's a folder in the Goodies folder that contains a Metrowerks project.
  2231. This is a static build, with everything linked into one app, since MW doesn't
  2232. support ASLM (more on that later.)
  2233.  
  2234. The future: Ever since we moved to SOM we've been using CodeWarrior PPC as
  2235. our primary development environment, and it works fine. So when the beta seed
  2236. is released RSN you'll be able to build parts with CodeWarrior -- if you have
  2237. a PowerPC. For 68k you'll need to use the Symantec compiler, until Metrowerks
  2238. releases a 68k version of CW that supports CFM68k. I know that MW plans to do
  2239. this but I will let them reveal their schedule :-)
  2240.  
  2241. Ken Prehoda, kenp@nmrfam.wisc.edu writes:
  2242. > ASLM seems like it is sooo much nicer than SOM.  Well I
  2243. > guess it isn't if you are not using C++ (or a C++ compiler that produces
  2244. > CFront compatible vtables, etc.).
  2245.  
  2246. ASLM is certainly simpler than SOM, and can be used in some niches that SOM
  2247. can't (mostly interrupt-level stuff like networking code, not surprising
  2248. since it was developed by the AppleTalk people.) But it has a lot of failings
  2249. -- not only that it's extremely compiler-dependent, but also that the
  2250. libraries are 'fragile' and any nontrivial change to an object's
  2251. implementation will break clients. It's also C++ centric, the downside of
  2252. which is that object-based libraries cannot be developed in any language but
  2253. C++.
  2254.  
  2255. Jason Bobier, jbobier@cybernetics.net writes:
  2256. > Why doesn't MW support the ASLM? Are they planning on supporting it?
  2257.  
  2258. Metrowerks doesn't support ASLM because it would require them to adopt
  2259. cfront's calling conventions, vtable format and name-mangling scheme. At
  2260. least two of these would be major steps backward for CW on 68k (the third is
  2261. the mangling; I've never understood why there was more than one name-mangling
  2262. system in the world, can someone explain?)
  2263. ASLM will continue to play a role in Mac software, but a minor one, mosty
  2264. dominated by the Open Transport networking protocols. Metrowerks (I'm putting
  2265. words in their mouths here) decided that wasn't as interesting as other stuff
  2266. they could be doing.
  2267.  
  2268. > Seems kinda strange that they don't when PP ships with a shared library...
  2269.  
  2270. That's a CFM shared library, not an ASLM library. You can sort-of do C++
  2271. object based libraries with CFM, provided you export your nonvirtual methods.
  2272. These libraries are (as with ASLM) highly dependent on the compiler and on
  2273. the exact versions of the library and its clients.
  2274.  
  2275. --Jens Alfke                           jens_alfke@powertalk.apple.com
  2276.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  2277.  
  2278. +++++++++++++++++++++++++++
  2279.  
  2280. >From nick+@pitt.edu ( nick.c )
  2281. Date: Sun, 18 Sep 94 23:21:35 GMT
  2282. Organization: The Pitt, Chemistry
  2283.  
  2284. In Article <35i4di$sd@bach.seattleu.edu>, boyerr@bach.seattleu.edu (Robert
  2285. A. Boyer) wrote:
  2286.  
  2287. >Does anyone have experience developing OpenDoc applications on a
  2288. >Macintosh using a development environment other than MPW?  What
  2289. >are the pros and cons of the following C++ development environments:
  2290. >MPW, Symantec, and Metroworks?
  2291.  
  2292.     With a6, you can only use MPW or Symantec.  MW doesn't support
  2293.       ASLM, however I've heard later releases of OpenDoc will be
  2294.       supported by CodeWarrior.  I'm still sketchy on details.
  2295.  
  2296.  
  2297.  
  2298.                                     _/   _/  _/  _/_/_/   _/   _/  
  2299.      Interet: nick@pitt.edu        _/_/ _/  _/  _/   _/  _/_/_/    
  2300.       eWorld: nick                _/ _/_/  _/  _/       _/ _/      
  2301.          CIS: 71232,766          _/   _/  _/   _/_/_/  _/   _/     
  2302.  
  2303.  
  2304. +++++++++++++++++++++++++++
  2305.  
  2306. >From philip@cs.wits.ac.za (Philip Machanick)
  2307. Date: 20 Sep 1994 13:20:51 GMT
  2308. Organization: Computer Science Dept, U of Witwatersrand
  2309.  
  2310. In article <1994Sep20.001043.28057@gallant.apple.com>, Jens Alfke
  2311. <jens_alfke@powertalk.apple.com> wrote:
  2312.  
  2313. > The future: Ever since we moved to SOM we've been using CodeWarrior PPC as
  2314. > our primary development environment, and it works fine. So when the beta seed
  2315. > is released RSN you'll be able to build parts with CodeWarrior -- if you have
  2316. > a PowerPC. For 68k you'll need to use the Symantec compiler, until Metrowerks
  2317. > releases a 68k version of CW that supports CFM68k. I know that MW plans to do
  2318. > this but I will let them reveal their schedule :-)
  2319.  
  2320. I hope they will.
  2321.  
  2322. Then it looks as if it may be worth my while to wait for the SOM/beta seed
  2323. before getting too heavily into this. I note you craftily failed to
  2324. mention the schedule for that ...
  2325. -- 
  2326. Philip Machanick                   philip@cs.wits.ac.za
  2327. Department of Computer Science, University of the Witwatersrand
  2328. 2050 Wits, South Africa        (at University of Cape Town 4 July-7 Nov)
  2329. phone 27(11)716-3309  fax 27(11)339-7965
  2330.  
  2331. ---------------------------
  2332.  
  2333. >From bb@lightside.com (Bob Bradley)
  2334. Subject: Q: Getting errors out of threads?
  2335. Date: Fri, 16 Sep 1994 15:16:37 -0800
  2336. Organization: SS Software Inc.
  2337.  
  2338. I'm using the Thread Manager to a series of long operations that can
  2339. generate errors and I'm looking for a better way to get those errors to
  2340. the user.
  2341.  
  2342. Right now I'm using OS Queues and when I get an error, I post an error
  2343. 'event' to the OS Queue which is picked up in my main thread's event loop
  2344. (I check for events in my OS queue just like I do the regular event
  2345. queue).
  2346.  
  2347. One problem is that sometimes I want to give the user the option to skip
  2348. the error and resume but, I'm having problems figuring a way to do it.
  2349.  
  2350. It also seems like using custom event queues just to display errors is
  2351. overkill, any thoughts?
  2352.  
  2353. +++++++++++++++++++++++++++
  2354.  
  2355. >From kenp@nmrfam.wisc.edu (Ken Prehoda)
  2356. Date: Sun, 18 Sep 1994 09:31:11 -0600
  2357. Organization: Univ of Wisc-Madison Dept of Biochemistry
  2358.  
  2359. In article <bb-1609941516370001@user50.lightside.com>, bb@lightside.com
  2360. (Bob Bradley) wrote:
  2361.  
  2362. > I'm using the Thread Manager to a series of long operations that can
  2363. > generate errors and I'm looking for a better way to get those errors to
  2364. > the user.
  2365. > Right now I'm using OS Queues and when I get an error, I post an error
  2366. > 'event' to the OS Queue which is picked up in my main thread's event loop
  2367. > (I check for events in my OS queue just like I do the regular event
  2368. > queue).
  2369. > One problem is that sometimes I want to give the user the option to skip
  2370. > the error and resume but, I'm having problems figuring a way to do it.
  2371. > It also seems like using custom event queues just to display errors is
  2372. > overkill, any thoughts?
  2373.  
  2374. It sure does.  What I did in this situation was just to create my own
  2375. queue as an application global that I would check through the event loop.
  2376.  
  2377. If you are using powerplant, there is an LSharedQueue class which uses a
  2378. somewhat more elegant mechanism to solve the problem of communication
  2379. between threads.
  2380.  
  2381. Ken Prehoda
  2382. University of Wisconsin-Madison
  2383. Department of Biochemistry
  2384. kenp@nmrfam.wisc.edu
  2385.  
  2386. +++++++++++++++++++++++++++
  2387.  
  2388. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  2389. Date: Mon, 19 Sep 1994 09:48:34 +0800
  2390. Organization: NCRPDA, Curtin University
  2391.  
  2392. In article <kenp-1809940931110001@f180-096.net.wisc.edu>,
  2393. kenp@nmrfam.wisc.edu (Ken Prehoda) wrote:
  2394.  
  2395. >> Right now I'm using OS Queues and when I get an error, I post an error
  2396. >> 'event' to the OS Queue which is picked up in my main thread's event loop
  2397. >> (I check for events in my OS queue just like I do the regular event
  2398. >> queue).
  2399. >> 
  2400. >> One problem is that sometimes I want to give the user the option to skip
  2401. >> the error and resume but, I'm having problems figuring a way to do it.
  2402.  
  2403. >It sure does.  What I did in this situation was just to create my own
  2404. >queue as an application global that I would check through the event loop.
  2405.  
  2406. Isn't that the same as what he said?  OS queues are just queues, you can
  2407. use the Enqueue and Dequeue functions with your own queues.  Here is what
  2408. I would do:
  2409.  
  2410. type 
  2411.   ThisThreadInformationPtr=^ThisThreadInformation;
  2412.   ThisThreadInformation=record
  2413.     qLink:ThisThreadInformationPtr; { MUST BE AT START OF RECORD! }
  2414.     error:OSErr;
  2415.     die:boolean;
  2416.     whatever else
  2417.   end;
  2418.  
  2419. Create New Thread:
  2420. data:=NewPtr(SizeOf(ThisThreadInformation));
  2421. data^.error:=1; { in progress }
  2422. data^.die:=false;
  2423. Enqueue(data,@threads);
  2424. NewThread(@DoThread,data);
  2425.  
  2426.  
  2427. DoThread(data:ThisThreadInformationPtr)
  2428. do your calculations as per normal.  If data^.die becomes true, give up.
  2429. If you get a potential error, set data^.error to it, and then wait:
  2430.  
  2431. procedure GotAnError(err:OSErr);
  2432. data^.error:=err;
  2433. while data^.error<>1 and not die do
  2434.   Yield
  2435. end-while
  2436.  
  2437. When we return from that, if die is true, then give up, otherwise
  2438. continue, ignoring or handling the error as appropriate.
  2439.  
  2440.  
  2441. Init:
  2442. threads.qHead:=nil;
  2443. threads.qTail:=nil;
  2444.  
  2445. In the Main loop:
  2446. for each data in threads queue do
  2447.   if data^.error=noErr then begin
  2448.     Signal Success
  2449.     Remove from queue
  2450.   end else if data^.error<>1 then begin
  2451.     Signal failure
  2452.     If the user wants it to abort
  2453.       set the die field to true
  2454.     otherwise
  2455.       set data^.error to 1 again so the thread will continue
  2456.     end-if
  2457.   end;  
  2458. end-for
  2459.  
  2460. You'll have to be careful about exactly who removes the entry from the
  2461. queue and disposes it, but it's not too tricky.
  2462.  
  2463. Just be thankful we dont have preemptive multitasking.  Ughh.  It makes
  2464. this much more horrible.
  2465.    Peter.
  2466. -- 
  2467. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  2468. FTP my programs from redback.cs.uwa.edu.au:Others/PeterLewis/ or
  2469. amug.org:pub/peterlewis/ or nic.switch.ch:software/mac/peterlewis/
  2470.  
  2471.  
  2472. ---------------------------
  2473.  
  2474. >From fba@cs.brown.edu (Farah B. Abbas)
  2475. Subject: Shared Memory on Mac
  2476. Date: Thu, 8 Sep 1994 16:46:20 GMT
  2477. Organization: Brown University Department of Computer Science
  2478.  
  2479. Hi,
  2480.  
  2481. Does anyone know how to implement shared memory on the Mac? I have an 
  2482. application that sets a variable that I want another app to read later. I guess
  2483. one way would be to use a code resource so that one application sets the 
  2484. variable in the resource and the other app can load the resource and 
  2485. thereby look up the variable. Is there a "Apple Suggested" way that is 
  2486. better or do I have to do this hack ? Please email any suggestions to 
  2487. fba@cs.brown.edu. Thanx in advance.
  2488.  
  2489. Farah
  2490.  
  2491. +++++++++++++++++++++++++++
  2492.  
  2493. >From rmah@panix.com (Robert Mah)
  2494. Date: Fri, 09 Sep 1994 03:24:53 -0500
  2495. Organization: One Step Beyond
  2496.  
  2497. fba@cs.brown.edu (Farah B. Abbas) wrote:
  2498.  
  2499. ) Does anyone know how to implement shared memory on the Mac? I have an 
  2500. ) application that sets a variable that I want another app to read later.
  2501. ) I guess one way would be to use a code resource so that one application
  2502. ) sets the variable in the resource and the other app can load the resource
  2503. ) and thereby look up the variable. Is there a "Apple Suggested" way that
  2504. ) is better or do I have to do this hack ?
  2505.  
  2506. I've been working on something to do just this.
  2507.  
  2508. It uses Gestalt to provide tagged, shared memory between apps (and any 
  2509. other code for that matter).
  2510.  
  2511. I've thought about using a trap, but decided against it as Apple sort of
  2512. has a hammerlock on the A-trap market :-).
  2513.  
  2514. In any case, to use it, one simply registers a block of memory with the
  2515. Shared Memory Manager (tm) and then can request it again later by using
  2516. the tag.
  2517.  
  2518. It is all very simple.  Would you like to test/work on it with it with me?
  2519.  
  2520. Cheers,
  2521. Rob
  2522. _____________________________________________________________________
  2523. Robert S. Mah           Software Development          +1.212.947.6507
  2524. One Step Beyond        and Network Consulting          rmah@panix.com
  2525.  
  2526. +++++++++++++++++++++++++++
  2527.  
  2528. >From lambert_l@measurex.com (Leon Lambert)
  2529. Date: Tue, 13 Sep 1994 20:04:31 GMT
  2530. Organization: measurex
  2531.  
  2532. In article <1994Sep8.164620.21157@cs.brown.edu>
  2533. fba@cs.brown.edu (Farah B. Abbas) writes:
  2534.  
  2535. > Hi,
  2536. > Does anyone know how to implement shared memory on the Mac? I have an 
  2537. > application that sets a variable that I want another app to read later. I guess
  2538. > one way would be to use a code resource so that one application sets the 
  2539. > variable in the resource and the other app can load the resource and 
  2540. > thereby look up the variable. Is there a "Apple Suggested" way that is 
  2541. > better or do I have to do this hack ? Please email any suggestions to 
  2542. > fba@cs.brown.edu. Thanx in advance.
  2543. > Farah
  2544.  
  2545. I did this by making an INIT that created a trap. But I now think a
  2546. better way to do this is to use the gestalt manager. It has the
  2547. ability to store and retrieve a 32 bit value. I haven't tried it yet
  2548. but maybe someone else has.
  2549.  
  2550. lambert_l@measurex.com (Leon Lambert)
  2551. lambertlb@aol.com
  2552.  
  2553. +++++++++++++++++++++++++++
  2554.  
  2555. >From Jaeger@fquest.com (Brian Stern)
  2556. Date: 14 Sep 1994 15:54:21 GMT
  2557. Organization: The University of Texas at Austin, Austin, Texas
  2558.  
  2559. In article <1994Sep8.164620.21157@cs.brown.edu>, fba@cs.brown.edu (Farah
  2560. B. Abbas) wrote:
  2561.  
  2562. < Hi,
  2563. < Does anyone know how to implement shared memory on the Mac? I have an 
  2564. < application that sets a variable that I want another app to read later.
  2565. I guess
  2566. < one way would be to use a code resource so that one application sets the 
  2567. < variable in the resource and the other app can load the resource and 
  2568. < thereby look up the variable. Is there a "Apple Suggested" way that is 
  2569. < better or do I have to do this hack ? Please email any suggestions to 
  2570. < fba@cs.brown.edu. Thanx in advance.
  2571. < Farah
  2572.  
  2573. Hi,
  2574.  
  2575. This can be done by putting the information in a preferences file that
  2576. both apps can open.  
  2577.  
  2578. You can install a gestalt selector that returns the address of this shared
  2579. memory.  Both the gestalt selector and the shared memory should exist in
  2580. the system heap if you do this, in case of crashes.  
  2581.  
  2582. This can also be implemented by creating a driver that returns the address
  2583. of the shared mem or that returns the actual values in the shared mem.
  2584.  
  2585. Good Luck,
  2586.  
  2587. -- 
  2588. Brian  Stern  :-{)}
  2589. Jaeger@fquest.com
  2590.  
  2591. +++++++++++++++++++++++++++
  2592.  
  2593. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  2594. Date: Mon, 19 Sep 1994 09:33:04 +0800
  2595. Organization: NCRPDA, Curtin University
  2596.  
  2597. In article <1994Sep8.164620.21157@cs.brown.edu>, fba@cs.brown.edu (Farah
  2598. B. Abbas) wrote:
  2599.  
  2600. >Does anyone know how to implement shared memory on the Mac? I have an 
  2601. >application that sets a variable that I want another app to read later. I guess
  2602. >one way would be to use a code resource so that one application sets the 
  2603. >variable in the resource and the other app can load the resource and 
  2604. >thereby look up the variable. Is there a "Apple Suggested" way that is 
  2605. >better or do I have to do this hack ? Please email any suggestions to 
  2606. >fba@cs.brown.edu. Thanx in advance.
  2607.  
  2608. Use Gestalt.  Have either or both applications install a gestalt handler
  2609. that returns the variable or the address of the variable.
  2610.  
  2611. WARNING: Do not assume you will be able to write (or perhaps even read)
  2612. another app's memory directly.  We desperately want Apple to give us
  2613. memory protection, at least between the various app's partitions, right?! 
  2614. If you want to share memory directly, then at least allocate the memory in
  2615. the System Heap, and use a Gestalt call to get the address of the memory.
  2616.  
  2617. Both apps could do something like:
  2618.  
  2619. If the gestalt call is already installed
  2620.   use the value returned as a ptr/handle to the data.
  2621. otherwise
  2622.   create the memory in the system heap
  2623.   load the gestalt code (probably also in the system heap)
  2624.   install the gestalt
  2625.   initialize the memory
  2626. end
  2627.  
  2628. After that, you can assume the gestalt call is installed and the memory is
  2629. available.
  2630.  
  2631. Enjoy,
  2632.    Peter.
  2633. -- 
  2634. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  2635. FTP my programs from redback.cs.uwa.edu.au:Others/PeterLewis/ or
  2636. amug.org:pub/peterlewis/ or nic.switch.ch:software/mac/peterlewis/
  2637.  
  2638. +++++++++++++++++++++++++++
  2639.  
  2640. >From chrism@col.hp.com (Chris Magnuson)
  2641. Date: 20 Sep 1994 17:05:56 GMT
  2642. Organization: HP Colorado Springs Division
  2643.  
  2644.   It *seems* like the PPC Toolbox might be okay for this.  There is an
  2645.   example of this on one of the developer CDs, where an INIT allocates
  2646.   some memory for shared globals and an application reads them.
  2647.  
  2648.   Chris Magnuson
  2649.   chrism@col.hp.com
  2650.  
  2651. ---------------------------
  2652.  
  2653. >From dbradley@Netaxs.com (Dan Bradley)
  2654. Subject: Window Lists
  2655. Date: 10 Sep 1994 19:10:49 GMT
  2656. Organization: Netaxs Internet BBS and Shell Accounts
  2657.  
  2658. Can anyone describe the process used to get a list of all open windows
  2659. within an application? I simply want to make an on the fly menu with
  2660. all the windows in my application in it. I thought of just updating the list
  2661. within my open, close, and save handlers, but it seems like it would be
  2662. a lot easier to just cycle through a list, which I'm sure must exist, but
  2663. I simply can't find, being a newbie who just doesn't know where to look.
  2664. I've been looking through IM, Think Ref, and Dave Mark's books, but
  2665. haven't found anything. I'm using Think C 6 and no TCL.
  2666.  
  2667. Thanks in advance,
  2668.  
  2669. Dan Bradley
  2670. dbradley@netaxs.com
  2671.  
  2672.  
  2673. +++++++++++++++++++++++++++
  2674.  
  2675. >From tnleeuw@cs.vu.nl (Leeuw van der TN)
  2676. Date: Mon, 12 Sep 1994 14:23:31 GMT
  2677. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  2678.  
  2679. dbradley@Netaxs.com (Dan Bradley) writes:
  2680. : Can anyone describe the process used to get a list of all open windows
  2681. : within an application? I simply want to make an on the fly menu with
  2682. : all the windows in my application in it. I thought of just updating the list
  2683. : within my open, close, and save handlers, but it seems like it would be
  2684. : a lot easier to just cycle through a list, which I'm sure must exist, but
  2685. : I simply can't find, being a newbie who just doesn't know where to look.
  2686. : I've been looking through IM, Think Ref, and Dave Mark's books, but
  2687. : haven't found anything. I'm using Think C 6 and no TCL.
  2688. : Thanks in advance,
  2689. : Dan Bradley
  2690. : dbradley@netaxs.com
  2691. Once I had a similar problem, when I wanted to get a list of my windows
  2692. so I could dispose of them when quitting. I came up with the AUXWinRec,
  2693. which you can call with a valid window record as a parameter, and gives
  2694. you the AuxWinRecord (sp?) for the Window *if* it is a color window.
  2695. *If* it is a color window, the owner field points to your window. Big Trick:
  2696. it also has a field pointing to the next AuxWinRec in the list,
  2697. which has of course an owner... So if you now what your first window
  2698. is (like, your about-box) you might be able to get the list.
  2699.  
  2700. I must admit that after I typed that code, I found the solution too scary
  2701. to really try it. I rewrote it using Frontwindow(). I've not seen it
  2702. documented anywhere what window is really next in the list. It might not
  2703. be yours.
  2704. I'm really curious how to do it.
  2705.  
  2706. --Tim van der Leeuw
  2707. tnleeuw@cs.vu.nl
  2708.  
  2709. +++++++++++++++++++++++++++
  2710.  
  2711. >From kurisuto@babel.ling.upenn.edu (Sean Crist)
  2712. Date: 12 Sep 1994 18:59:18 GMT
  2713. Organization: University of Pennsylvania, Linguistics Department
  2714.  
  2715. Unless I'm mistaken, it's still kosher to write your program as if all its
  2716. windows are in one linked list.  There's so many applications that step
  2717. through their own windows this way that Apple really can't change this
  2718. without breaking an awful lot of applications.  If I remember right,
  2719. though, FrontWindow returns the first _visible_ window, and you might want
  2720. to start with invisible ones, so you've got to look in some low-memory
  2721. pointer to really start at the front of the window list.
  2722.  
  2723. I'm talking off the top of my head; I've got some Pascal code at home that
  2724. illustrates this but I might be wrong in a few of the details.
  2725.  
  2726. --Sean
  2727.  
  2728.  
  2729. +++++++++++++++++++++++++++
  2730.  
  2731. >From cswan@actrix.gen.nz (Chris Swan)
  2732. Date: Wed, 14 Sep 1994 00:58:40 GMT
  2733. Organization: Actrix Information Exchange
  2734.  
  2735. > : Can anyone describe the process used to get a list of all open windows
  2736. > : within an application? I simply want to make an on the fly menu with
  2737.  
  2738. > Once I had a similar problem, when I wanted to get a list of my windows
  2739. > so I  [deleted - really complex answer] tting. 
  2740.  
  2741. theWindow := FrontWindow;
  2742. while theWindow <> nil do
  2743.   begin
  2744.    Do_Some_thing(with, theWindow);
  2745.    theWindow:= windowPtr(windowPeek(theWindow)^.nextWindow);
  2746.   end;
  2747.  
  2748. Ref. Inside Macintosh Volume I
  2749.  
  2750. -- 
  2751. Chris Swan
  2752. cswan@actrix.gen.nz
  2753. PO Box 11567, Wellington, New Zealand
  2754. --
  2755.  
  2756. +++++++++++++++++++++++++++
  2757.  
  2758. >From Tim_Craycroft@PowerTalk.apple.com (Tim Craycroft)
  2759. Date: Wed, 14 Sep 1994 00:40:00 GMT
  2760. Organization: Apple Computer
  2761.  
  2762. In article <Cw0tB8.2IL@cs.vu.nl>, tnleeuw@cs.vu.nl (Leeuw van der TN)
  2763. wrote:
  2764. > dbradley@Netaxs.com (Dan Bradley) writes:
  2765. > : Can anyone describe the process used to get a list of all open windows
  2766. > : within an application? I simply want to make an on the fly menu with
  2767. > : all the windows in my application in it. I thought of just updating the list
  2768. > : within my open, close, and save handlers, but it seems like it would be
  2769. > : a lot easier to just cycle through a list, which I'm sure must exist, but
  2770. > : I simply can't find, being a newbie who just doesn't know where to look.
  2771. > : I've been looking through IM, Think Ref, and Dave Mark's books, but
  2772. > : haven't found anything. I'm using Think C 6 and no TCL.
  2773. > : 
  2774. > : Thanks in advance,
  2775. > : 
  2776. > : Dan Bradley
  2777. > : dbradley@netaxs.com
  2778. > : 
  2779. > Once I had a similar problem, when I wanted to get a list of my windows
  2780. > so I could dispose of them when quitting. I came up with the AUXWinRec,
  2781. > which you can call with a valid window record as a parameter, and gives
  2782. > you the AuxWinRecord (sp?) for the Window *if* it is a color window.
  2783. > *If* it is a color window, the owner field points to your window. Big Trick:
  2784. > it also has a field pointing to the next AuxWinRec in the list,
  2785. > which has of course an owner... So if you now what your first window
  2786. > is (like, your about-box) you might be able to get the list.
  2787. > I must admit that after I typed that code, I found the solution too scary
  2788. > to really try it. I rewrote it using Frontwindow(). I've not seen it
  2789. > documented anywhere what window is really next in the list. It might not
  2790. > be yours.
  2791. > I'm really curious how to do it.
  2792. > --Tim van der Leeuw
  2793. > tnleeuw@cs.vu.nl
  2794.  
  2795. You want to iterate over your window list.  Get the first window by calling
  2796. LMGetWindowList().  The link field in the window record is ->nextWindow. 
  2797. If you are just interested in visible windows, you can use FrontWindow()
  2798. instead of LMGetWindowList() and then check the ->visible field of all
  2799. subsequent windows in the list.  Do NOT use the aux record list.  There is
  2800. no guarantee that the link field in the aux record is an aux record of a
  2801. window you own.
  2802.  
  2803.  
  2804. //
  2805. // Accessor macros that will someday be replace by real window mgr APIs
  2806. //
  2807.  
  2808. #define    GetNextWindow(w)            (((WindowPeek) w)->nextWindow)    
  2809. #define IsWindowVisible(w)    (((WindowPeek) w)->visible)
  2810.  
  2811.  
  2812. DoSomethingWithMyWindows(Boolean onlyVisible)
  2813. {
  2814.         WindowRef    currentWindow;
  2815.  
  2816.      currentWindow = LMGetWindowList();
  2817.  
  2818.         while (currentWindow != 0)
  2819.      {
  2820.                     if (!onlyVisible || ( IsWindowVisible(currentWindow) )
  2821.                  {        
  2822.                             // do something with this window...
  2823.                          DoSomethingToOneWindow(currentWindow);
  2824.                  }
  2825.  
  2826.               currentWindow = GetNextWindow(currentWindow);
  2827.      }
  2828. }
  2829.  
  2830. +++++++++++++++++++++++++++
  2831.  
  2832. >From h+@nada.kth.se (Jon W{tte)
  2833. Date: Wed, 14 Sep 1994 18:36:53 +0200
  2834. Organization: Royal Institute of Something or other
  2835.  
  2836. In article <Cw3HDs.2qx@actrix.gen.nz>,
  2837. cswan@actrix.gen.nz (Chris Swan) wrote:
  2838.  
  2839. >theWindow := FrontWindow;
  2840. >while theWindow <> nil do
  2841. >  begin
  2842. >   Do_Some_thing(with, theWindow);
  2843. >   theWindow:= windowPtr(windowPeek(theWindow)^.nextWindow);
  2844. >  end;
  2845.  
  2846. Close, but no cigar. FrontWindow() returns the first visible 
  2847. window, but the nextWindow pointer can return an invisible 
  2848. window.
  2849.  
  2850.     WindowPtr window = FrontWindow ( ) ;
  2851.     while ( window )
  2852.     {
  2853.         DoSomeThing ( window ) ;
  2854.         do {
  2855.             window = ( WindowPtr ) ( ( WindowPeek ) window ) -> 
  2856.                 nextWindow ;
  2857.         } while ( window && ! ( ( WindowPeek ) window ) -> visible ) ;
  2858.     }
  2859.  
  2860. The Window Manager is desperately in need of a lot of accessor 
  2861. functions, by the way.
  2862.  
  2863. Cheers,
  2864.  
  2865.                 / h+
  2866.  
  2867.  
  2868. --
  2869.   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  2870.  ~r ~/.signature
  2871.  
  2872.  
  2873. +++++++++++++++++++++++++++
  2874.  
  2875. >From larson@oahu.cs.ucla.edu (Christopher Larson)
  2876. Date: Wed, 14 Sep 94 16:26:12 GMT
  2877. Organization: UCLA, Computer Science Department
  2878.  
  2879. In article <Cw3HDs.2qx@actrix.gen.nz> cswan@actrix.gen.nz (Chris Swan) writes:
  2880. >> : Can anyone describe the process used to get a list of all open windows
  2881. >> : within an application? I simply want to make an on the fly menu with
  2882. >
  2883. >> Once I had a similar problem, when I wanted to get a list of my windows
  2884. >> so I  [deleted - really complex answer] tting. 
  2885. >
  2886. >theWindow := FrontWindow;
  2887.               ^^^^^^^^^^^
  2888. >while theWindow <> nil do
  2889. >  begin
  2890. >   Do_Some_thing(with, theWindow);
  2891. >   theWindow:= windowPtr(windowPeek(theWindow)^.nextWindow);
  2892. >  end;
  2893. >
  2894. >Ref. Inside Macintosh Volume I
  2895.  
  2896. If memory serves, FrontWindow() returns the frontmost _visible_ window. You
  2897. may miss hidden windows this way. Try starting with the LM global WindowList.
  2898.  
  2899. --Chris
  2900. _______________________________________________________________________________
  2901. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  2902. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  2903. Death to the Trojans! Go Bruins!
  2904.  
  2905. (Insert disclaimer here)
  2906. Internet: larson@kingston.cs.ucla.edu
  2907.  
  2908. +++++++++++++++++++++++++++
  2909.  
  2910. >From tnleeuw@cs.vu.nl (Leeuw van der TN)
  2911. Date: Thu, 15 Sep 1994 11:36:45 GMT
  2912. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  2913.  
  2914. cswan@actrix.gen.nz (Chris Swan) writes:
  2915. : > : Can anyone describe the process used to get a list of all open windows
  2916. : > : within an application? I simply want to make an on the fly menu with
  2917. : > Once I had a similar problem, when I wanted to get a list of my windows
  2918. : > so I  [deleted - really complex answer] tting. 
  2919. : theWindow := FrontWindow;
  2920. : while theWindow <> nil do
  2921. :   begin
  2922. :    Do_Some_thing(with, theWindow);
  2923. :    theWindow:= windowPtr(windowPeek(theWindow)^.nextWindow);
  2924. :   end;
  2925. I still don't understand how I could have overlooked that field. Really stupid,
  2926. actually. Sorry. Anyway, I understand that you can get the first window by
  2927. calling FrontWindow()? It's not the window that you first created?
  2928. : Ref. Inside Macintosh Volume I
  2929. : -- 
  2930. : Chris Swan
  2931. : cswan@actrix.gen.nz
  2932. : PO Box 11567, Wellington, New Zealand
  2933. : --
  2934. --Tim van der Leeuw
  2935. tnleeuw@cs.vu.nl
  2936.  
  2937. +++++++++++++++++++++++++++
  2938.  
  2939. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  2940. Date: Mon, 19 Sep 1994 20:35:15 GMT
  2941. Organization: Apple Computer
  2942.  
  2943. In article <34t0bp$jkt@netaxs.com> Dan Bradley, dbradley@Netaxs.com writes:
  2944. > Can anyone describe the process used to get a list of all open windows
  2945. > within an application?
  2946.  
  2947. Start with FrontWindow(), then follow the nextWindow fields in each
  2948. windowRecord. Note that WindowPtr is just another name for GrafPtr, so you
  2949. won't be able to access the extra WindowRecord fields through it. You have to
  2950. cast to WindowPeek (defined as a pointer to WindowRecord).
  2951.  
  2952. WindowPtr w;
  2953. for( w=FrontWindow(); w; w=(WindowPtr)((WindowPeek)w)->nextWindow )
  2954.     if( ((WindowPeek)w)->windowKind >= userKind )
  2955.         /*do something with w*/;
  2956.  
  2957. Note that this loop intentionally skips non-document windows like dialogs,
  2958. DAs and other system windows.
  2959.  
  2960. --Jens Alfke                           jens_alfke@powertalk.apple.com
  2961.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  2962.  
  2963. ---------------------------
  2964.  
  2965. >From paitech@hntp2.hinet.net (paitech)
  2966. Subject: preloaded CODE resources in fat binaries
  2967. Date: 9 Sep 1994 08:28:52 GMT
  2968. Organization: NCTU News Server, HiNet
  2969.  
  2970. In the 68k world, we usually mark the resident CODE segments LOCKED and
  2971. PRELOADED, to avoid memory fragmentation.  But under the Power Macintosh
  2972. runtime architecture, these preloaded CODE segments just waste memory.
  2973.  
  2974. So how should I do to these CODE resources in the fat binaries?  Currently
  2975. I put the following piece of code at the beginning of my program, and it
  2976. looks ugly.  Are there any better methods?
  2977.  
  2978.     #ifdef __powerc
  2979.         for (short seg_idx = Count1Resources('CODE'); seg_idx > 0; --seg_idx)
  2980.         {   SetResLoad(false);
  2981.             Handle seg = Get1IndResource('CODE', seg_idx);
  2982.             SetResLoad(true);
  2983.             if (seg)
  2984.                 ReleaseResource(seg);
  2985.         }
  2986.     #endif
  2987.  
  2988. Hao-yang Wang
  2989. Pai Technology, Inc.
  2990. Taipei
  2991.  
  2992. +++++++++++++++++++++++++++
  2993.  
  2994. >From gurgle@dnai.com (Pete Gontier)
  2995. Date: Fri, 09 Sep 1994 12:48:15 -0800
  2996. Organization: Integer Poet Software
  2997.  
  2998. In article <34p6c4$jqo@serv.hinet.net>, paitech@hntp2.hinet.net (paitech) wrote:
  2999.  
  3000. > In the 68k world, we usually mark the resident CODE segments LOCKED and
  3001. > PRELOADED, to avoid memory fragmentation.  But under the Power Macintosh
  3002. > runtime architecture, these preloaded CODE segments just waste memory.
  3003. > So how should I do to these CODE resources in the fat binaries?  Currently
  3004. > I put the following piece of code at the beginning of my program...
  3005.  
  3006. [code to get and release code segments omitted]
  3007.  
  3008. Interesting problem. I realized you have a problem just the opposite of
  3009. the one I try to solve in my code, which is that pre-loaded segments don't
  3010. work the same when your app is not an app (i.e. when it's a TPM project).
  3011. See, in that case you have to go get the code segments yourself and lock
  3012. them low in the heap.
  3013.  
  3014. I think this is useful information for you because (1) it's an example of
  3015. someone else doing a disgusting hack against the CODE resources and pretty
  3016. much getting away with it, and (2) it provides you with code you might
  3017. want to use instead of marking your segments pre-loaded. That way, for the
  3018. PPC version, you can simply omit the code.
  3019.  
  3020. //////////////////////////////////////////////////////////////////////////////
  3021.  
  3022. #if defined (THINK_C) || defined (applec)
  3023.  
  3024. //  Note selectivity of above compilers; under Metrowerks we
  3025. //  assume the linker has been set to merge the whole app into
  3026. //  one huge resource. Probably we should later include an
  3027. //  explicit check for this, but right now I am using the
  3028. //  CD ROM drive for music and can't look up the symbols. :-/
  3029.  
  3030. static OSErr MacLow_Init_LoadCODEs (void)
  3031. {
  3032.     OSErr oe = noErr;
  3033.  
  3034.     //  This code attempts to load all the code segments low in the heap and
  3035.     //  lock them down. If we're not running under TPM, this should have been
  3036.     //  done already for us by the fact that all the code resources should be
  3037.     //  marked pre-load and lock in the resource map. If we are, we need to
  3038.     //  take extra steps.
  3039.     //  
  3040.     //  First, we check to see if we are running under TPM. Since the TPM
  3041.     //  opens an external, non-CODE resource file on top of the project file,
  3042.     //  where the CODE resources live, we can search the top resource file for
  3043.     //  CODEs to find out if the TPM has done this. And an easy way to do this
  3044.     //  is Count1Resources.
  3045.  
  3046.     Boolean tpmRunning = false;
  3047.     short code = Count1Resources ('CODE');
  3048.  
  3049.     if (!(oe = ResError ( )) && !code)
  3050.     {
  3051.         //  OK, now we know we are running under TPM.
  3052.         //  We need to get the "real" count of the CODE resources.
  3053.         //  We can do this by searching beyond the current file,
  3054.         //  which will catch the CODEs in the project.
  3055.  
  3056.         tpmRunning = true;
  3057.         code = CountResources ('CODE');
  3058.         oe = ResError ( );
  3059.     }
  3060.  
  3061.     if (!oe)
  3062.     {
  3063.         //  Now index all of
  3064.         //  them and get their IDs without loading them, reserve
  3065.         //  space for them at the bottom of the heap, load them,
  3066.         //  and lock them.
  3067.  
  3068.         Handle      codeH;
  3069.         Size        size;
  3070.         short       id;
  3071.         ResType     type;
  3072.         Str255      name;
  3073.  
  3074.         if (code)
  3075.         {
  3076.             Boolean oldResLoad = LMGetResLoad ( );
  3077.             SetResLoad (false);
  3078.  
  3079.             do
  3080.             {
  3081.                 if (tpmRunning)
  3082.                     codeH = GetIndResource ('CODE', code);
  3083.                 else
  3084.                     codeH = Get1IndResource ('CODE', code);
  3085.  
  3086.                 oe = ResError ( ); if (oe) break;
  3087.                 GetResInfo (codeH, &id, &type, name);
  3088.                 oe = ResError ( ); if (oe) break;
  3089.  
  3090.                 //  Skip the jump table and the startup code.
  3091.                 //  This should be more intelligent about how
  3092.                 //  various linkers handle their startup code.
  3093.                 //  It's presently set up for THINK, but may
  3094.                 //  work in other cases.
  3095.  
  3096.                 if (id != 0 && id != 1)
  3097.                 {
  3098.                     size = GetResourceSizeOnDisk (codeH);
  3099.                     oe = ResError ( ); if (oe) break;
  3100.                     ReserveMem (size);
  3101.                     oe = MemError ( ); if (oe) break;
  3102.                     LoadResource (codeH);
  3103.                     oe = ResError ( ); if (oe) break;
  3104.                     HLock (codeH);
  3105.                     oe = MemError ( ); if (oe) break;
  3106.                     HNoPurge (codeH); // just for paranoia
  3107.                     oe = MemError ( ); if (oe) break;
  3108.                 }
  3109.             }
  3110.             while (--code);
  3111.  
  3112.             SetResLoad (oldResLoad);
  3113.         }
  3114.     }
  3115.  
  3116.     return (oe);
  3117. }
  3118.  
  3119. #endif
  3120.  
  3121. -- 
  3122.  
  3123.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  3124.  
  3125.  "The need to be (or appear to be) sophisticated pervades the very
  3126.  atmosphere in which we, the Magazine Reading Class, move."
  3127.                   -- Ellis Weiner, Spy Magazine, 9/94
  3128.  
  3129. +++++++++++++++++++++++++++
  3130.  
  3131. >From paitech@hntp2.hinet.net (paitech)
  3132. Date: 10 Sep 1994 18:51:43 GMT
  3133. Organization: NCTU News Server, HiNet
  3134.  
  3135. Pete Gontier (gurgle@dnai.com) wrote:
  3136. : much getting away with it, and (2) it provides you with code you might
  3137. : want to use instead of marking your segments pre-loaded. That way, for the
  3138. : PPC version, you can simply omit the code.
  3139.  
  3140. But you still have to preload the main segment (i.e. CODE 1), right?
  3141.  
  3142. Hao-yang Wang
  3143. Pai Technology, Inc.
  3144. Taipei
  3145.  
  3146. +++++++++++++++++++++++++++
  3147.  
  3148. >From gurgle@dnai.com (Pete Gontier)
  3149. Date: Sat, 10 Sep 1994 18:14:54 -0800
  3150. Organization: Integer Poet Software
  3151.  
  3152. In article <34sv7v$8hr@serv.hinet.net>, paitech@hntp2.hinet.net (paitech) wrote:
  3153.  
  3154. > Pete Gontier (gurgle@dnai.com) wrote:
  3155. > : much getting away with it, and (2) it provides you with code you might
  3156. > : want to use instead of marking your segments pre-loaded. That way, for the
  3157. > : PPC version, you can simply omit the code.
  3158. > But you still have to preload the main segment (i.e. CODE 1), right?
  3159.  
  3160. I'm not terribly familiar with the PPC code model, so it's possible you
  3161. might have to do this, but I think it's always a pretty safe assumption
  3162. that if your code is running, CODE 1 loaded successfully. :-)
  3163.  
  3164. -- 
  3165.  
  3166.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  3167.  
  3168.  "The need to be (or appear to be) sophisticated pervades the very
  3169.  atmosphere in which we, the Magazine Reading Class, move."
  3170.                   -- Ellis Weiner, Spy Magazine, 9/94
  3171.  
  3172. +++++++++++++++++++++++++++
  3173.  
  3174. >From paitech@hntp2.hinet.net (paitech)
  3175. Date: 11 Sep 1994 08:50:52 GMT
  3176. Organization: NCTU News Server, HiNet
  3177.  
  3178. Pete Gontier (gurgle@dnai.com) wrote:
  3179. : > But you still have to preload the main segment (i.e. CODE 1), right?
  3180.  
  3181. : I'm not terribly familiar with the PPC code model, so it's possible you
  3182. : might have to do this, but I think it's always a pretty safe assumption
  3183. : that if your code is running, CODE 1 loaded successfully. :-)
  3184.  
  3185. Let me make my question clearer:
  3186.  
  3187. You suggested that instead of marking the resident segments PRELOADED, we can
  3188. also load them manually at runtime.  This is a good idea (It cannot be bad
  3189. because MacApp has done it in a similar way since 1.0.), but when your code is
  3190. executed (under 68k), the main segment is already loaded (into the middle of
  3191. the heap?) and it is already too late to reallocate the main segment.
  3192.  
  3193. So the main segment should still be marked as PRELOADED and we still have to
  3194. release it under PPC, right?
  3195.  
  3196. Hao-yang Wang
  3197. Pai Technology, Inc.
  3198. Taipei
  3199.  
  3200. +++++++++++++++++++++++++++
  3201.  
  3202. >From h+@nada.kth.se (Jon W{tte)
  3203. Date: Sun, 11 Sep 1994 19:47:54 +0200
  3204. Organization: Royal Institute of Something or other
  3205.  
  3206. In article <34ugdc$pqk@serv.hinet.net>,
  3207. paitech@hntp2.hinet.net (paitech) wrote:
  3208.  
  3209. >You suggested that instead of marking the resident segments PRELOADED, we can
  3210. >also load them manually at runtime.  This is a good idea (It cannot be bad
  3211. >because MacApp has done it in a similar way since 1.0.), but when your code is
  3212. >executed (under 68k), the main segment is already loaded (into the middle of
  3213. >the heap?) and it is already too late to reallocate the main segment.
  3214.  
  3215. >So the main segment should still be marked as PRELOADED and we still have to
  3216. >release it under PPC, right?
  3217.  
  3218.  
  3219. No.
  3220.  
  3221. The Segment Loader loads CODE 0 and whatever's referenced by 
  3222. the first jump table entry for you. At this time, the heap is 
  3223. really small (MaxApplZone() hasn't been called) and there's 
  3224. nothing else in it (what would it be? No memory allocation's 
  3225. been done) so that CODE resource is loaded snugly in the heap; 
  3226. no fragmentation.
  3227.  
  3228. If your main() function is not in the same segment as the 
  3229. startup loader bootstrap (runtime library) you'll have a third 
  3230. CODE resource load before you get to the start of main, and 
  3231. still MaxApplZone() isn't called and no non-permanent memory is 
  3232. allocated to there's no chance of fragmentation.
  3233.  
  3234. So, don't mark CODE 0 or CODE 1 (or ANY CODE) preloaded for a 
  3235. fat binary.
  3236.  
  3237. OR special-case for PPC to get all CODE resources and release 
  3238. them :-) :-) :-)
  3239.  
  3240. Cheers,
  3241.  
  3242.                 / h+
  3243.  
  3244.  
  3245. --
  3246.   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  3247.  
  3248.    Nothing crashes like a Macintosh.
  3249.                      -- Guy Kawasaki
  3250.  
  3251.  
  3252. +++++++++++++++++++++++++++
  3253.  
  3254. >From paitech@hntp2.hinet.net (paitech)
  3255. Date: 12 Sep 1994 13:55:17 GMT
  3256. Organization: NCTU News Server, HiNet
  3257.  
  3258. Jon W{tte (h+@nada.kth.se) wrote:
  3259. : The Segment Loader loads CODE 0 and whatever's referenced by 
  3260. : the first jump table entry for you. At this time, the heap is 
  3261. : really small (MaxApplZone() hasn't been called) and there's 
  3262. : nothing else in it (what would it be? No memory allocation's 
  3263. : been done) so that CODE resource is loaded snugly in the heap; 
  3264. : no fragmentation.
  3265.  
  3266. There is still fragmentation.  You can break into Macsbug and check for it
  3267. yourself.  It is not caused by other memory allocations, but by the MiveHHi()
  3268. call (made by the Segment Loader).  However, the heap is really small at this
  3269. time, so the memory loss caused by this fragmentation may be no more than
  3270. several kilo bytes.  We may just ignore this fragmentation.
  3271.  
  3272. : So, don't mark CODE 0 or CODE 1 (or ANY CODE) preloaded for a 
  3273. : fat binary.
  3274.  
  3275. In CodeWarrior, this is easy.  In MPW, you may need to write a rez script for
  3276. this post-link process.  I don't know an easy way to clear the preloaded bit
  3277. under the Symantec environment.
  3278.  
  3279. Another related problem is the SIZE resource.  On one hand, under the PPC
  3280. runtime environment the code does not take up the application heap, on the
  3281. other hand, the PPC stack size is usually larger than the 68k one.  Anyway,
  3282. if the memory requirements for PPC and 68k are different, how can one SIZE
  3283. fit for both?
  3284.  
  3285. I am writing a fat 'appe', and the SIZE resource becomes a problem, because
  3286. 1) users cannot change the memory partition in the "Get Info..." Finder
  3287.    dialog for the 'appe';
  3288. 2) the 'appe' will always resident in background and take up memory, so I
  3289.    cannot throw away hundreds of kilo bytes here and there, as I used to do.
  3290.  
  3291. Maybe I should put an INIT resource into the  the appe file, to adjust the
  3292. SIZE resource dynamically at the startup time, according to the current
  3293. machine architecture.  But I think I have used up all my quota on dirty
  3294. tricks this year. :-)
  3295.  
  3296. Hao-yang Wang
  3297. Pai Technology, Inc.
  3298. Taipei
  3299.  
  3300. +++++++++++++++++++++++++++
  3301.  
  3302. >From gurgle@dnai.com (Pete Gontier)
  3303. Date: Mon, 12 Sep 1994 10:22:25 -0800
  3304. Organization: Integer Poet Software
  3305.  
  3306. In article <351mk5$sus@serv.hinet.net>, paitech@hntp2.hinet.net (paitech) wrote:
  3307.  
  3308. > There is still fragmentation.  You can break into Macsbug and check for it
  3309. > yourself.  It is not caused by other memory allocations, but by the MiveHHi()
  3310. > call (made by the Segment Loader).  However, the heap is really small at this
  3311. > time, so the memory loss caused by this fragmentation may be no more than
  3312. > several kilo bytes.  We may just ignore this fragmentation.
  3313.  
  3314. Ah. After some twiddling of my own current project, I see what you are
  3315. getting at. For various technical reasons, I was not running into the
  3316. problem. My code was only intended to get around the tricky resource fork
  3317. problem in the TPM. The real solution for 68K is to have all your code
  3318. segments locked and pre-loaded, which is fine, because my TPM solution
  3319. knows whether it's running under TPM and bails out if not.
  3320.  
  3321. But you still have a problem -- how to make the 68K code all load and stay
  3322. loaded without fragmenting the heap while at the same time *not* loading
  3323. when the PPC code runs. Making sure the 68K code does not waste RAM while
  3324. the PPC code is running not only requires you to get and release the CODE
  3325. resources but *also* costs you startup time, because those resources take
  3326. some non-zero time to be read in from the disk, even when running under
  3327. PPC.
  3328.  
  3329. As you say, though, the heap is really small at that time, and you might
  3330. just want to sacrifice the wasted space to the gods of convenience.
  3331. Anyway, I will think about this some more as a mental background process,
  3332. for whatever that's worth. :-)
  3333.  
  3334. -- 
  3335.  
  3336.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  3337.  
  3338.  "The need to be (or appear to be) sophisticated pervades the very
  3339.  atmosphere in which we, the Magazine Reading Class, move."
  3340.                   -- Ellis Weiner, Spy Magazine, 9/94
  3341.  
  3342. +++++++++++++++++++++++++++
  3343.  
  3344. >From wdh@fresh.com (Bill Hofmann)
  3345. Date: Mon, 12 Sep 1994 17:36:24 GMT
  3346. Organization: Fresh Software
  3347.  
  3348. In article <34ugdc$pqk@serv.hinet.net>, paitech@hntp2.hinet.net (paitech) wrote:
  3349.  
  3350. > Let me make my question clearer:
  3351. > You suggested that instead of marking the resident segments PRELOADED, we can
  3352. > also load them manually at runtime.  This is a good idea (It cannot be bad
  3353. > because MacApp has done it in a similar way since 1.0.), but when your code is
  3354. > executed (under 68k), the main segment is already loaded (into the middle of
  3355. > the heap?) and it is already too late to reallocate the main segment.
  3356. > So the main segment should still be marked as PRELOADED and we still have to
  3357. > release it under PPC, right?
  3358. > Hao-yang Wang
  3359. > Pai Technology, Inc.
  3360. > Taipei
  3361. No.  The system loads CODE 1 (and CODE 0) itself in the process of launching your application if it's a 68k app.  You really don't have to mark any resources preload except your error reporting resources (DLOG or ALRT, DITL, STRs or STR#s, etc).  You don't have to mark CODE 1 preload.
  3362. -- 
  3363. Bill Hofmann                                   wdh@fresh.com
  3364. Fresh Software and Instructional Design        voice: +1 510 524 0852
  3365. 1640 San Pablo Ave #C Berkeley CA 94702 USA    fax:   +1 510 524 0853
  3366.  
  3367. +++++++++++++++++++++++++++
  3368.  
  3369. >From gurgle@dnai.com (Pete Gontier)
  3370. Date: Mon, 12 Sep 1994 12:20:17 -0800
  3371. Organization: Integer Poet Software
  3372.  
  3373. In article <wdh-1209941036240001@wdh.slip.netcom.com>, wdh@fresh.com (Bill
  3374. Hofmann) wrote:
  3375.  
  3376. > You really don't have to mark any resources 
  3377. > preload except your error reporting resources
  3378. > (DLOG or ALRT, DITL, STRs or STR#s, etc).
  3379.  
  3380. I think perhaps you are missing the idea that he *wants* to pre-load all
  3381. his code resources so that he doesn't have to worry about the memory
  3382. management issues associated with code segments loading and unloading via
  3383. Segment Loader and the jump table. It's not that he thinks he must; he's
  3384. choosing to do so in order to make his memory management simpler. This is
  3385. not optimal in terms of memory usage, but code takes up a surprisingly
  3386. small amount of relative space in some apps, and making sure it's all
  3387. always loaded can simplify QA a lot.
  3388.  
  3389. -- 
  3390.  
  3391.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  3392.  
  3393.  "The need to be (or appear to be) sophisticated pervades the very
  3394.  atmosphere in which we, the Magazine Reading Class, move."
  3395.                   -- Ellis Weiner, Spy Magazine, 9/94
  3396.  
  3397. +++++++++++++++++++++++++++
  3398.  
  3399. >From gurgle@dnai.com (Pete Gontier)
  3400. Date: Mon, 12 Sep 1994 12:25:50 -0800
  3401. Organization: Integer Poet Software
  3402.  
  3403. In article <wdh-1209941036240001@wdh.slip.netcom.com>, wdh@fresh.com (Bill
  3404. Hofmann) wrote:
  3405.  
  3406. > The system loads CODE 1 (and CODE 0) itself in the process of
  3407. > launching your application if it's a 68k app... You don't have to mark
  3408. > CODE 1 preload.
  3409.  
  3410. I forgot to note something else:
  3411.  
  3412. Most development systems automatically mark CODE 1 as pre-loaded. This has
  3413. the effect of forcing the segment into the lowest possible position in the
  3414. heap as soon as the app's resource file is opened. (Ordinarily this is a
  3415. good thing, because CODE 1 tends to do things like patch ExitToShell, and
  3416. you don't want it moving around.) It may be that under some systems the
  3417. process manager does the right thing to make sure this happens anyway, but
  3418. since most development systems mark CODE 1 as pre-loaded regardless, it's
  3419. still a good idea to figure out how to deal with it under PowerPC in a fat
  3420. binary situation.
  3421.  
  3422. -- 
  3423.  
  3424.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  3425.  
  3426.  "The need to be (or appear to be) sophisticated pervades the very
  3427.  atmosphere in which we, the Magazine Reading Class, move."
  3428.                   -- Ellis Weiner, Spy Magazine, 9/94
  3429. >From Pete.Gontier@f1.n100.z60.wlink.nl (Pete Gontier)
  3430. Subject: preloaded CODE resources in fat binaries
  3431. Date: Mon, 12 Sep 1994 14:25:50 -0100
  3432. Organization: (none)
  3433.  
  3434.  
  3435. In article <wdh-1209941036240001@wdh.slip.netcom.com>, wdh@fresh.com (Bill
  3436. Hofmann) wrote:
  3437.  
  3438. > The system loads CODE 1 (and CODE 0) itself in the process of
  3439. > launching your application if it's a 68k app... You don't have to mark
  3440. > CODE 1 preload.
  3441.  
  3442. I forgot to note s
  3443.  
  3444.  
  3445.  
  3446.  
  3447. +++++++++++++++++++++++++++
  3448.  
  3449. >From wdh@fresh.com (Bill Hofmann)
  3450. Date: Thu, 15 Sep 1994 17:18:00 GMT
  3451. Organization: Fresh Software
  3452.  
  3453. In article <gurgle-1209941220170001@dynamic-210.dnai.com>, gurgle@dnai.com
  3454. (Pete Gontier) wrote:
  3455. > I think perhaps you are missing the idea that he *wants* to pre-load all
  3456. > his code resources so that he doesn't have to worry about the memory
  3457. > management issues associated with code segments loading and unloading via
  3458. > Segment Loader and the jump table. It's not that he thinks he must....
  3459. Well, no, I didn't miss it, but his question seemed to indicate that he thought that he *had* to.  If he's still listening, I'd suggest something like this:
  3460.  
  3461. #ifndef powerc
  3462.     <preload code resources>
  3463. #endif
  3464.  
  3465. That'll do it.  But preloading and other memory management things should be done at the end of the development process, when you can spend a lot of time staring at Macsbug heap displays.   I hold that nowadays it's much less of an issue than it was 8 years ago.
  3466. -- 
  3467. Bill Hofmann                                   wdh@fresh.com
  3468. Fresh Software and Instructional Design        voice: +1 510 524 0852
  3469. 1640 San Pablo Ave #C Berkeley CA 94702 USA    fax:   +1 510 524 0853
  3470.  
  3471. +++++++++++++++++++++++++++
  3472.  
  3473. >From gurgle@dnai.com (Pete Gontier)
  3474. Date: Fri, 16 Sep 1994 10:25:41 -0800
  3475. Organization: Integer Poet Software
  3476.  
  3477. In article <wdh-1509941018000001@wdh.slip.netcom.com>, wdh@fresh.com (Bill
  3478. Hofmann) wrote:
  3479.  
  3480. > #ifndef powerc
  3481. >     <preload code resources>
  3482. > #endif
  3483.  
  3484. He can do that, but if he does, CODE 1 and the segment which contains
  3485. 'main' and the segment which contains the code which loads the rest of the
  3486. segments may already have been loaded in a sub-optimal place. (In fact,
  3487. they are almost guranteed to have been.) He wants a solution which (a)
  3488. doesn't require him to worry about what code goes where, and (b) doesn't
  3489. create any heap islands. The traditional solution of marking all the code
  3490. segments pre-loaded and locked doesn't, of course, work under PPC in a fat
  3491. binary because the code segments should *never* be loaded in that case.
  3492. That's why this is such a vexing problem.
  3493.  
  3494. > But preloading and other memory management things should be done at the end
  3495. > of the development process, when you can spend a lot of time...
  3496.  
  3497. That's precisely when when you *cannot* spend a lot of time! :-) Anyway, I
  3498. think if you are going to adopt the policy of not messing with the segment
  3499. loader at all, it's prudent to make that part of the program work right up
  3500. front. You should see the colors my face turns when I'm trying to debug
  3501. one crash and another crash happens because of something like a segment
  3502. loader error. :-)
  3503.  
  3504. > I hold that nowadays it's much less of an issue than it was 8 years ago.
  3505.  
  3506. Right. That's why he wants to dispense with that pesky Segment Loader.
  3507.  
  3508. -- 
  3509.  
  3510.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  3511.  
  3512.  "I saw John Norstad with Elvis! And they were varnishing waffles!"
  3513.       -- Peter Cohen <flargh@tiac.net>
  3514.  
  3515. ---------------------------
  3516.  
  3517. End of C.S.M.P. Digest
  3518. **********************
  3519.  
  3520.  
  3521. ˇ